8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 17:23:03 +01:00

Add configuration parameter DefaultProfilerPlugin.

Change RDB$PROFILER.START_SESSION parameters order and put defaults on them.
This commit is contained in:
Adriano dos Santos Fernandes 2022-05-13 22:20:10 -03:00
parent 0c5874eed9
commit a8ae90d9f7
6 changed files with 28 additions and 12 deletions

View File

@ -508,6 +508,12 @@
#
#UserManager = Srp
# Default profiler plugin used to profile connections using the RDB$PROFILER package.
#
# Per-database configurable.
#
#DefaultProfilerPlugin = Default_Profiler
# TracePlugin is used by firebird trace facility to send trace data to the user
# or log file in audit case.
#

View File

@ -55,7 +55,7 @@ set term ;!
-- Start profiling
select rdb$profiler.start_session('Default_Profiler', 'Profile Session 1') from rdb$database;
select rdb$profiler.start_session('Profile Session 1') from rdb$database;
set term !;
@ -72,7 +72,7 @@ execute procedure rdb$profiler.finish_session(true);
execute procedure ins;
select rdb$profiler.start_session('Default_Profiler', 'Profile Session 2') from rdb$database;
select rdb$profiler.start_session('Profile Session 2') from rdb$database;
select mod(id, 5),
sum(val)
@ -122,9 +122,11 @@ select pstat.*
`RDB$PROFILER.START_SESSION` starts a new profiler session, turns it the current session and return its identifier.
If `PLUGIN_NAME` is `NULL` (the default) it uses the database configuration `DefaultProfilerPlugin`.
Input parameters:
- `PLUGIN_NAME` type `VARCHAR(255) CHARACTER SET UTF8`
- `DESCRIPTION` type `VARCHAR(255) CHARACTER SET UTF8`
- `DESCRIPTION` type `VARCHAR(255) CHARACTER SET UTF8` default `NULL`
- `PLUGIN_NAME` type `VARCHAR(255) CHARACTER SET UTF8` default `NULL`
Return type: `BIGINT NOT NULL`.

View File

@ -647,6 +647,12 @@ const char* Config::getPlugins(unsigned int type) const
aKey = key;
break;
}
case IPluginManager::TYPE_PROFILER:
{
DECLARE_PER_DB_KEY(KEY_PLUG_PROFILER);
aKey = key;
break;
}
case IPluginManager::TYPE_TRACE:
{
DECLARE_PER_DB_KEY(KEY_PLUG_TRACE);

View File

@ -65,9 +65,9 @@
type getParameterName() const;
form, for world-wide (global) parameters
static type getParameterName();
should be used. Also, for world-wide parameters, values of default
should be used. Also, for world-wide parameters, values of default
config instance (see getDefaultConfig()) should be used.
5. Macros CONFIG_GET_GLOBAL_XXX and CONFIG_GET_PER_DB_XXX helps to
5. Macros CONFIG_GET_GLOBAL_XXX and CONFIG_GET_PER_DB_XXX helps to
declare and implement trivial getXXX functions and to enforce rule (4).
**/
@ -163,6 +163,7 @@ enum ConfigKey
KEY_PLUG_AUTH_SERVER,
KEY_PLUG_AUTH_CLIENT,
KEY_PLUG_AUTH_MANAGE,
KEY_PLUG_PROFILER,
KEY_PLUG_TRACE,
KEY_SECURITY_DATABASE,
KEY_SERVER_MODE,
@ -271,6 +272,7 @@ constexpr ConfigEntry entries[MAX_CONFIG_KEY] =
{TYPE_STRING, "AuthClient", false, "Srp256, Srp, Legacy_Auth"},
#endif
{TYPE_STRING, "UserManager", false, "Srp"},
{TYPE_STRING, "DefaultProfilerPlugin", false, "Default_Profiler"},
{TYPE_STRING, "TracePlugin", false, "fbtrace"},
{TYPE_STRING, "SecurityDatabase", false, nullptr}, // sec/db alias - rely on ConfigManager::getDefaultSecurityDb(
{TYPE_STRING, "ServerMode", true, nullptr}, // actual value differs in boot/regular cases and set at setupDefaultConfig(
@ -434,7 +436,7 @@ public:
// CONFIG_GET_GLOBAL_XXX (CONFIG_GET_PER_DB_XXX) set of macros helps to
// create trivial static (non-static) getXXX functions.
// create trivial static (non-static) getXXX functions.
// Correctness of declaration and implementation is enforced with help
// of entries[XXX].is_global.

View File

@ -151,8 +151,8 @@ void ProfilerPackage::startSessionFunction(ThrowStatusExceptionWrapper* /*status
const auto attachment = tdbb->getAttachment();
const auto transaction = tdbb->getTransaction();
const PathName pluginName(in->pluginName.str, in->pluginName.length);
const string description(in->description.str, in->descriptionNull ? 0 : in->description.length);
const PathName pluginName(in->pluginName.str, in->pluginNameNull ? 0 : in->pluginName.length);
const auto profilerManager = attachment->getProfilerManager(tdbb);
AutoSetRestore<bool> pauseProfiler(&profilerManager->paused, true);
@ -200,7 +200,7 @@ SINT64 ProfilerManager::startSession(thread_db* tdbb, const PathName& pluginName
}
else
{
GetPlugins<IProfilerPlugin> plugins(IPluginManager::TYPE_PROFILER, pluginName.c_str());
GetPlugins<IProfilerPlugin> plugins(IPluginManager::TYPE_PROFILER, pluginName.nullStr());
if (!plugins.hasData())
{
@ -578,8 +578,8 @@ ProfilerPackage::ProfilerPackage(MemoryPool& pool)
SystemFunctionFactory<StartSessionInput, StartSessionOutput, startSessionFunction>(),
// parameters
{
{"PLUGIN_NAME", fld_file_name2, true},
{"DESCRIPTION", fld_short_description, true}
{"DESCRIPTION", fld_short_description, true, "null", {blr_null}},
{"PLUGIN_NAME", fld_file_name2, true, "null", {blr_null}},
},
{fld_prof_ses_id, false}
)

View File

@ -163,9 +163,9 @@ private:
//----------
FB_MESSAGE(StartSessionInput, Firebird::ThrowStatusExceptionWrapper,
(FB_INTL_VARCHAR(255, CS_METADATA), description)
(FB_INTL_VARCHAR(255, CS_METADATA), pluginName)
//// TODO: Options: PSQL, SQL.
(FB_INTL_VARCHAR(255, CS_METADATA), description)
//// TODO: Plugin options.
);