2022-11-09 12:37:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/AsynchronousMetrics.h>
|
|
|
|
#include <Interpreters/Context_fwd.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ServerAsynchronousMetrics : public AsynchronousMetrics, WithContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ServerAsynchronousMetrics(
|
|
|
|
ContextPtr global_context_,
|
|
|
|
int update_period_seconds,
|
|
|
|
int heavy_metrics_update_period_seconds,
|
|
|
|
const ProtocolServerMetricsFunc & protocol_server_metrics_func_);
|
|
|
|
private:
|
2022-11-10 11:56:27 +00:00
|
|
|
void updateImpl(AsynchronousMetricValues & new_values, TimePoint update_time, TimePoint current_time) override;
|
2022-11-09 12:37:42 +00:00
|
|
|
void logImpl(AsynchronousMetricValues & new_values) override;
|
|
|
|
|
|
|
|
const Duration heavy_metric_update_period;
|
|
|
|
TimePoint heavy_metric_previous_update_time;
|
|
|
|
|
|
|
|
struct DetachedPartsStats
|
|
|
|
{
|
|
|
|
size_t count;
|
|
|
|
size_t detached_by_user;
|
|
|
|
};
|
|
|
|
|
|
|
|
DetachedPartsStats detached_parts_stats{};
|
|
|
|
|
|
|
|
void updateDetachedPartsStats();
|
|
|
|
void updateHeavyMetricsIfNeeded(TimePoint current_time, TimePoint update_time, AsynchronousMetricValues & new_values);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|