diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-06-02 17:05:42 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-06-02 17:05:42 +0300 |
commit | b93c9c23c9b51d4a1bfd26a5b400186315e89976 (patch) | |
tree | 093f23b182af1176526148dae1fb5abc5e008194 /library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp | |
parent | c768b09694655b942cfd5bc66db6c8c2ece24f75 (diff) | |
download | ydb-b93c9c23c9b51d4a1bfd26a5b400186315e89976.tar.gz |
intermediate changes
ref:8868513666cce733c1c659c7f2d683ffab1150dd
Diffstat (limited to 'library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp')
-rw-r--r-- | library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp b/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp index 15efeb8c03..f3015c48bc 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp +++ b/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp @@ -2,6 +2,7 @@ #include "prometheus_model.h" #include <library/cpp/monlib/encode/encoder_state.h> +#include <library/cpp/monlib/encode/buffered/string_pool.h> #include <library/cpp/monlib/metrics/labels.h> #include <library/cpp/monlib/metrics/metric_value.h> @@ -311,6 +312,16 @@ namespace NMonitoring { } } + void OnLabel(ui32 name, ui32 value) override { + OnLabel(LabelNamesPool_.Get(name), LabelValuesPool_.Get(value)); + } + + std::pair<ui32, ui32> PrepareLabel(TStringBuf name, TStringBuf value) override { + auto nameLabel = LabelNamesPool_.PutIfAbsent(name); + auto valueLabel = LabelValuesPool_.PutIfAbsent(value); + return std::make_pair(nameLabel->Index, valueLabel->Index); + } + void OnDouble(TInstant time, double value) override { State_.Expect(TEncoderState::EState::METRIC); MetricState_.Time = time; @@ -403,6 +414,9 @@ namespace NMonitoring { TInstant CommonTime_ = TInstant::Zero(); TLabels CommonLabels_; TMetricState MetricState_; + + TStringPoolBuilder LabelNamesPool_; + TStringPoolBuilder LabelValuesPool_; }; } |