diff --git a/src/include/main/db_main.h b/src/include/main/db_main.h index 91c197d078..41730b24ea 100644 --- a/src/include/main/db_main.h +++ b/src/include/main/db_main.h @@ -907,6 +907,7 @@ class DBMain { uint8_t pipeline_metrics_sample_rate_ = 10; bool transaction_metrics_ = false; bool logging_metrics_ = false; + uint8_t logging_metrics_sample_rate_ = 100; bool gc_metrics_ = false; bool bind_command_metrics_ = false; bool execute_command_metrics_ = false; @@ -998,6 +999,7 @@ class DBMain { query_trace_metrics_ = settings_manager->GetBool(settings::Param::query_trace_metrics_enable); pipeline_metrics_ = settings_manager->GetBool(settings::Param::pipeline_metrics_enable); pipeline_metrics_sample_rate_ = settings_manager->GetInt(settings::Param::pipeline_metrics_sample_rate); + logging_metrics_sample_rate_ = settings_manager->GetInt(settings::Param::logging_metrics_sample_rate); transaction_metrics_ = settings_manager->GetBool(settings::Param::transaction_metrics_enable); logging_metrics_ = settings_manager->GetBool(settings::Param::logging_metrics_enable); gc_metrics_ = settings_manager->GetBool(settings::Param::gc_metrics_enable); @@ -1023,6 +1025,7 @@ class DBMain { std::unique_ptr metrics_manager = std::make_unique(); metrics_manager->SetMetricSampleRate(metrics::MetricsComponent::EXECUTION_PIPELINE, pipeline_metrics_sample_rate_); + metrics_manager->SetMetricSampleRate(metrics::MetricsComponent::LOGGING, logging_metrics_sample_rate_); if (query_trace_metrics_) metrics_manager->EnableMetric(metrics::MetricsComponent::QUERY_TRACE); if (pipeline_metrics_) metrics_manager->EnableMetric(metrics::MetricsComponent::EXECUTION_PIPELINE); diff --git a/src/include/settings/settings_callbacks.h b/src/include/settings/settings_callbacks.h index 1a8bf72dca..8b3bbab938 100644 --- a/src/include/settings/settings_callbacks.h +++ b/src/include/settings/settings_callbacks.h @@ -138,6 +138,16 @@ class Callbacks { static void MetricsPipeline(void *old_value, void *new_value, DBMain *db_main, common::ManagedPointer action_context); + /** + * Update the sampling interval for logging + * @param old_value old settings value + * @param new_value new settings value + * @param db_main pointer to db_main + * @param action_context pointer to the action context for this settings change + */ + static void MetricsLoggingSampleRate(void *old_value, void *new_value, DBMain *db_main, + common::ManagedPointer action_context); + /** * Update the sampling interval for ExecutionEngine pipelines * @param old_value old settings value diff --git a/src/include/settings/settings_defs.h b/src/include/settings/settings_defs.h index 68798559e4..2d2e27a803 100644 --- a/src/include/settings/settings_defs.h +++ b/src/include/settings/settings_defs.h @@ -313,6 +313,16 @@ SETTING_int( noisepage::settings::Callbacks::MetricsPipelineSampleRate ) +SETTING_int( + logging_metrics_sample_rate, + "Sampling rate of metrics collection for logging.", + 100, + 0, + 100, + true, + noisepage::settings::Callbacks::MetricsLoggingSampleRate +) + SETTING_bool( bind_command_metrics_enable, "Metrics collection for the bind command.", diff --git a/src/settings/settings_callbacks.cpp b/src/settings/settings_callbacks.cpp index 6e7ae78eb6..50955ba656 100644 --- a/src/settings/settings_callbacks.cpp +++ b/src/settings/settings_callbacks.cpp @@ -132,6 +132,14 @@ void Callbacks::MetricsPipelineSampleRate(void *old_value, void *new_value, DBMa action_context->SetState(common::ActionState::SUCCESS); } +void Callbacks::MetricsLoggingSampleRate(void *old_value, void *new_value, DBMain *db_main, + common::ManagedPointer action_context) { + action_context->SetState(common::ActionState::IN_PROGRESS); + int interval = *static_cast(new_value); + db_main->GetMetricsManager()->SetMetricSampleRate(metrics::MetricsComponent::LOGGING, static_cast(interval)); + action_context->SetState(common::ActionState::SUCCESS); +} + void Callbacks::MetricsBindCommand(void *const old_value, void *const new_value, DBMain *const db_main, common::ManagedPointer action_context) { action_context->SetState(common::ActionState::IN_PROGRESS);