aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/providers/common/metrics/metrics_registry.h
blob: d344ba9dd9873291170958c49be56b3a21f4f2aa (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once

#include "sensors_group.h"

#include <util/generic/yexception.h>

namespace NYql {

namespace NProto {
class TMetricsRegistrySnapshot;
}

struct IMetricsRegistry;
using IMetricsRegistryPtr = TIntrusivePtr<IMetricsRegistry>;

using TMetricsDecorator = std::function<IMetricsRegistryPtr(
        const IMetricsRegistryPtr& old, const TString& username)>;

//////////////////////////////////////////////////////////////////////////////
// IYqlMetricsRegistry
//////////////////////////////////////////////////////////////////////////////
struct IMetricsRegistry: public TThrRefBase {

    virtual void SetCounter(
        const TString& labelName,
        const TString& labelValue,
        i64 value,
        bool derivative = false) = 0;

    virtual void IncCounter(
            const TString& labelName,
            const TString& labelValue,
            bool derivative = true) = 0;

    virtual void AddCounter(
            const TString& labelName,
            const TString& labelValue,
            i64 value,
            bool derivative = true) = 0;

    // will invalidate all counters
    virtual bool TakeSnapshot(
            NProto::TMetricsRegistrySnapshot* snapshot) const = 0;

    virtual void MergeSnapshot(
            const NProto::TMetricsRegistrySnapshot& snapshot) = 0;

    virtual IMetricsRegistryPtr Personalized(
            const TString& userName) const = 0;

    virtual void Flush() = 0;

    virtual TSensorsGroupPtr GetSensors() {
        ythrow yexception() << "Not implemented";
    }
};


IMetricsRegistryPtr CreateMetricsRegistry(TSensorsGroupPtr sensors);

} // namespace NYql