#pragma once #include #include #include #include #include #include namespace DB { /** MetricLog is a log of metric values measured at regular time interval. */ struct MetricLogElement { time_t event_time{}; UInt64 milliseconds{}; std::vector profile_events; std::vector current_metrics; static std::string name() { return "MetricLog"; } static Block createBlock(); void appendToBlock(Block & block) const; }; class MetricLog : public SystemLog { using SystemLog::SystemLog; public: /// Launches a background thread to collect metrics with interval void startCollectMetric(size_t collect_interval_milliseconds_); /// Stop background thread. Call before shutdown. void stopCollectMetric(); private: void metricThreadFunction(); ThreadFromGlobalPool metric_flush_thread; size_t collect_interval_milliseconds; std::atomic is_shutdown_metric_thread{false}; }; }