aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/ServerAsynchronousMetrics.h
blob: 8243699a11162c0398b6940b2762046241723932 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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:
    void updateImpl(AsynchronousMetricValues & new_values, TimePoint update_time, TimePoint current_time) override;
    void logImpl(AsynchronousMetricValues & new_values) override;

    const Duration heavy_metric_update_period;
    TimePoint heavy_metric_previous_update_time;
    double heavy_update_interval = 0.;

    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);
};

}