Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Add support for arbitrary SHOW. Add "set log_level_blah". (#1591)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmwnshn authored Jun 3, 2021
1 parent b6f1d56 commit a283c6a
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 183 deletions.
9 changes: 9 additions & 0 deletions src/include/loggers/loggers_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// flush the debug logs, every <n> seconds
#define DEBUG_LOG_FLUSH_INTERVAL 3

#include <optional>
#include <string_view>

#include "common/sanctioned_shared_pointer.h"
#include "spdlog/fmt/ostr.h"
#include "spdlog/sinks/basic_file_sink.h"
Expand All @@ -29,5 +32,11 @@ class LoggersUtil {
* Shut down all of the debug loggers in the system.
*/
static void ShutDown();

/** @return The specified level. */
static std::optional<spdlog::level::level_enum> GetLevel(const std::string_view &name);

/** @return The logger for the specified component. */
static noisepage::common::SanctionedSharedPtr<spdlog::logger>::Ptr GetLogger(const std::string_view &name);
};
} // namespace noisepage
4 changes: 2 additions & 2 deletions src/include/main/db_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,8 @@ class DBMain {
bytecode_handlers_path_ = settings_manager->GetString(settings::Param::bytecode_handlers_path);

query_trace_metrics_ = settings_manager->GetBool(settings::Param::query_trace_metrics_enable);
query_trace_metrics_output_ = static_cast<metrics::MetricsOutput>(metrics::MetricsUtil::FromMetricsOutputString(
settings_manager->GetString(settings::Param::query_trace_metrics_output)));
query_trace_metrics_output_ = *metrics::MetricsUtil::FromMetricsOutputString(
settings_manager->GetString(settings::Param::query_trace_metrics_output));
forecast_sample_limit_ = settings_manager->GetInt(settings::Param::forecast_sample_limit);
pipeline_metrics_ = settings_manager->GetBool(settings::Param::pipeline_metrics_enable);
pipeline_metrics_sample_rate_ = settings_manager->GetInt(settings::Param::pipeline_metrics_sample_rate);
Expand Down
20 changes: 11 additions & 9 deletions src/include/metrics/metrics_util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <chrono> // NOLINT
#include <optional>
#include <string>

#include "execution/util/cpu_info.h"
Expand Down Expand Up @@ -39,15 +40,16 @@ struct MetricsUtil {
* @param metrics output string
* @return MetricsOutput corresponding to it
*/
static MetricsOutput FromMetricsOutputString(const std::string &metrics) {
if (metrics == "CSV") return MetricsOutput::CSV;

if (metrics == "DB") return MetricsOutput::DB;

if (metrics == "CSV_AND_DB") return MetricsOutput::CSV_AND_DB;

NOISEPAGE_ASSERT(false, "Unknown metrics type specified");
return MetricsOutput::CSV;
static std::optional<MetricsOutput> FromMetricsOutputString(const std::string_view &metrics) {
std::optional<MetricsOutput> type{std::nullopt};
if (metrics == "CSV") {
type = MetricsOutput::CSV;
} else if (metrics == "DB") {
type = MetricsOutput::DB;
} else if (metrics == "CSV_AND_DB") {
type = MetricsOutput::CSV_AND_DB;
}
return type;
}

/**
Expand Down
208 changes: 47 additions & 161 deletions src/include/settings/settings_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,234 +28,120 @@ class Callbacks {
static void NoOp(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Changes the buffer segment pool size limit.
* @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
*/
/** Change the buffer segment pool size limit. */
static void BufferSegmentPoolSizeLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Changes the buffer segment pool reuse limit.
* @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
*/
/** Change the buffer segment pool reuse limit. */
static void BufferSegmentPoolReuseLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Changes the block store size limit.
* @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
*/
/** Change the block store size limit. */
static void BlockStoreSizeLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Changes the block store reuse limit.
* @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
*/
/** Change the block store reuse limit. */
static void BlockStoreReuseLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Changes the number of buffers the log manager uses.
* @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
*/
/** Change the number of buffers the log manager uses. */
static void WalNumBuffers(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Changes the number of buffers the log manager uses.
* @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
*/
/** Change the number of buffers the log manager uses. */
static void WalSerializationInterval(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for Logging component
* @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
*/
/** Enable or disable metrics collection for Logging component. */
static void MetricsLogging(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for TransactionManager component
* @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
*/
/** Enable or disable metrics collection for TransactionManager component. */
static void MetricsTransaction(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for GarbageCollector component
* @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
*/
/** Enable or disable metrics collection for GarbageCollector component. */
static void MetricsGC(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for Execution component
* @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
*/
/** Enable or disable metrics collection for Execution component. */
static void MetricsExecution(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for ExecutionEngine pipeline
* @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
*/
/** Enable or disable metrics collection for ExecutionEngine pipeline. */
static void MetricsPipeline(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> 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
*/
/** Update the sampling interval for logging. */
static void MetricsLoggingSampleRate(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Update the sampling interval for ExecutionEngine pipelines
* @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
*/
/** Update the sampling interval for ExecutionEngine pipelines. */
static void MetricsPipelineSampleRate(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for bind command
* @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
*/
/** Enable or disable metrics collection for bind command. */
static void MetricsBindCommand(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for execute command
* @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
*/
/** Enable or disable metrics collection for execute command. */
static void MetricsExecuteCommand(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable metrics collection for Query Trace component
* @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
*/
/** Enable or disable metrics collection for Query Trace component. */
static void MetricsQueryTrace(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Update the metrics output type being used by a metric component
* @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
*/
/** Update the metrics output type being used by a metric component. */
static void MetricsQueryTraceOutput(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Set the forecast sample limit
* @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
*/
/** Set the forecast sample limit. */
static void ForecastSampleLimit(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Set the number of task manager threads
* @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
*/
/** Set the number of task manager threads. */
static void TaskPoolSize(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Enable or disable planning in Pilot thread
* @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
*/
/** Enable or disable planning in Pilot thread. */
static void PilotEnablePlanning(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Train the forecast model
* @param old_value old settings value (not relevant)
* @param new_value new settings value (not relevant)
* @param db_main pointer to db_main
* @param action_context pointer to the action context for this settings change
*/
/** Train the forecast model. */
static void TrainForecastModel(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Train the interference model
* @param old_value old settings value (not relevant)
* @param new_value new settings value (not relevant)
* @param db_main pointer to db_main
* @param action_context pointer to the action context for this settings change
*/
/** Train the interference model. */
static void TrainInterferenceModel(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

/**
* Train the OU model
* @param old_value old settings value (not relevant)
* @param new_value new settings value (not relevant)
* @param db_main pointer to db_main
* @param action_context pointer to the action context for this settings change
*/
/** Train the OU model. */
static void TrainOUModel(void *old_value, void *new_value, DBMain *db_main,
common::ManagedPointer<common::ActionContext> action_context);

#define SETTINGS_GENERATE_LOGGER_CALLBACK(component) \
/** Set the log level for the component. */ \
static void LogLevelSet##component(void *old_value, void *new_value, DBMain *db_main, \
common::ManagedPointer<common::ActionContext> action_context);

SETTINGS_GENERATE_LOGGER_CALLBACK(binder)
SETTINGS_GENERATE_LOGGER_CALLBACK(catalog)
SETTINGS_GENERATE_LOGGER_CALLBACK(common)
SETTINGS_GENERATE_LOGGER_CALLBACK(execution)
SETTINGS_GENERATE_LOGGER_CALLBACK(index)
SETTINGS_GENERATE_LOGGER_CALLBACK(messenger)
SETTINGS_GENERATE_LOGGER_CALLBACK(metrics)
SETTINGS_GENERATE_LOGGER_CALLBACK(modelserver)
SETTINGS_GENERATE_LOGGER_CALLBACK(network)
SETTINGS_GENERATE_LOGGER_CALLBACK(optimizer)
SETTINGS_GENERATE_LOGGER_CALLBACK(parser)
SETTINGS_GENERATE_LOGGER_CALLBACK(replication)
SETTINGS_GENERATE_LOGGER_CALLBACK(selfdriving)
SETTINGS_GENERATE_LOGGER_CALLBACK(settings)
SETTINGS_GENERATE_LOGGER_CALLBACK(storage)
SETTINGS_GENERATE_LOGGER_CALLBACK(transaction)

#undef SETTINGS_GENERATE_LOGGER_CALLBACK
};
} // namespace noisepage::settings
30 changes: 30 additions & 0 deletions src/include/settings/settings_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,34 @@ SETTING_int(
noisepage::settings::Callbacks::NoOp
)


// The default log level is unspecified because people may have inserted calls
// to set_level directly in the codebase, which would make a default inaccurate.
#define SETTINGS_LOG_LEVEL(component) \
SETTING_string( \
log_level_##component, \
"Set the log level for the component.", \
"(unspecified)", \
true, \
noisepage::settings::Callbacks::LogLevelSet##component \
)

SETTINGS_LOG_LEVEL(binder)
SETTINGS_LOG_LEVEL(catalog)
SETTINGS_LOG_LEVEL(common)
SETTINGS_LOG_LEVEL(execution)
SETTINGS_LOG_LEVEL(index)
SETTINGS_LOG_LEVEL(messenger)
SETTINGS_LOG_LEVEL(metrics)
SETTINGS_LOG_LEVEL(modelserver)
SETTINGS_LOG_LEVEL(network)
SETTINGS_LOG_LEVEL(optimizer)
SETTINGS_LOG_LEVEL(parser)
SETTINGS_LOG_LEVEL(replication)
SETTINGS_LOG_LEVEL(selfdriving)
SETTINGS_LOG_LEVEL(settings)
SETTINGS_LOG_LEVEL(storage)
SETTINGS_LOG_LEVEL(transaction)

#undef SETTINGS_LOG_LEVEL
// clang-format on
Loading

0 comments on commit a283c6a

Please sign in to comment.