diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:03 +0300 |
commit | 2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5 (patch) | |
tree | b83306b6e37edeea782e9eed673d89286c4fef35 /library/cpp/monlib/metrics/metric_registry.h | |
parent | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (diff) | |
download | ydb-2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/metric_registry.h')
-rw-r--r-- | library/cpp/monlib/metrics/metric_registry.h | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/library/cpp/monlib/metrics/metric_registry.h b/library/cpp/monlib/metrics/metric_registry.h index e308065da9..670cf8651e 100644 --- a/library/cpp/monlib/metrics/metric_registry.h +++ b/library/cpp/monlib/metrics/metric_registry.h @@ -1,17 +1,17 @@ -#pragma once - -#include "labels.h" -#include "metric.h" - +#pragma once + +#include "labels.h" +#include "metric.h" + #include <util/system/rwlock.h> - + #include <library/cpp/threading/light_rw_lock/lightrwlock.h> -namespace NMonitoring { - class IMetricFactory { +namespace NMonitoring { + class IMetricFactory { public: - virtual ~IMetricFactory() = default; + virtual ~IMetricFactory() = default; virtual IGauge* Gauge(ILabelsPtr labels) = 0; virtual ILazyGauge* LazyGauge(ILabelsPtr labels, std::function<double()> supplier) = 0; @@ -36,27 +36,27 @@ namespace NMonitoring { public: virtual ~IMetricSupplier() = default; - virtual void Accept(TInstant time, IMetricConsumer* consumer) const = 0; - virtual void Append(TInstant time, IMetricConsumer* consumer) const = 0; + virtual void Accept(TInstant time, IMetricConsumer* consumer) const = 0; + virtual void Append(TInstant time, IMetricConsumer* consumer) const = 0; }; class IMetricRegistry: public IMetricSupplier, public IMetricFactory { public: virtual const TLabels& CommonLabels() const noexcept = 0; - virtual void RemoveMetric(const ILabels& labels) noexcept = 0; + virtual void RemoveMetric(const ILabels& labels) noexcept = 0; }; - /////////////////////////////////////////////////////////////////////////////// - // TMetricRegistry - /////////////////////////////////////////////////////////////////////////////// - class TMetricRegistry: public IMetricRegistry { - public: - TMetricRegistry(); - ~TMetricRegistry(); - - explicit TMetricRegistry(const TLabels& commonLabels); - + /////////////////////////////////////////////////////////////////////////////// + // TMetricRegistry + /////////////////////////////////////////////////////////////////////////////// + class TMetricRegistry: public IMetricRegistry { + public: + TMetricRegistry(); + ~TMetricRegistry(); + + explicit TMetricRegistry(const TLabels& commonLabels); + /** * Get a global metrics registry instance. */ @@ -66,19 +66,19 @@ namespace NMonitoring { TLazyGauge* LazyGauge(TLabels labels, std::function<double()> supplier); TIntGauge* IntGauge(TLabels labels); TLazyIntGauge* LazyIntGauge(TLabels labels, std::function<i64()> supplier); - TCounter* Counter(TLabels labels); + TCounter* Counter(TLabels labels); TLazyCounter* LazyCounter(TLabels labels, std::function<ui64()> supplier); TRate* Rate(TLabels labels); TLazyRate* LazyRate(TLabels labels, std::function<ui64()> supplier); - - THistogram* HistogramCounter( + + THistogram* HistogramCounter( TLabels labels, - IHistogramCollectorPtr collector); - - THistogram* HistogramRate( + IHistogramCollectorPtr collector); + + THistogram* HistogramRate( TLabels labels, - IHistogramCollectorPtr collector); - + IHistogramCollectorPtr collector); + /** * Set all registered metrics to zero */ @@ -88,21 +88,21 @@ namespace NMonitoring { */ void Clear(); - void Accept(TInstant time, IMetricConsumer* consumer) const override; - void Append(TInstant time, IMetricConsumer* consumer) const override; - + void Accept(TInstant time, IMetricConsumer* consumer) const override; + void Append(TInstant time, IMetricConsumer* consumer) const override; + const TLabels& CommonLabels() const noexcept override { - return CommonLabels_; - } - - void RemoveMetric(const ILabels& labels) noexcept override; + return CommonLabels_; + } - private: + void RemoveMetric(const ILabels& labels) noexcept override; + + private: TGauge* Gauge(ILabelsPtr labels) override; TLazyGauge* LazyGauge(ILabelsPtr labels, std::function<double()> supplier) override; TIntGauge* IntGauge(ILabelsPtr labels) override; TLazyIntGauge* LazyIntGauge(ILabelsPtr labels, std::function<i64()> supplier) override; - TCounter* Counter(ILabelsPtr labels) override; + TCounter* Counter(ILabelsPtr labels) override; TLazyCounter* LazyCounter(ILabelsPtr labels, std::function<ui64()> supplier) override; TRate* Rate(ILabelsPtr labels) override; TLazyRate* LazyRate(ILabelsPtr labels, std::function<ui64()> supplier) override; @@ -117,13 +117,13 @@ namespace NMonitoring { private: TRWMutex Lock_; - THashMap<ILabelsPtr, IMetricPtr> Metrics_; + THashMap<ILabelsPtr, IMetricPtr> Metrics_; - template <typename TMetric, EMetricType type, typename TLabelsType, typename... Args> - TMetric* Metric(TLabelsType&& labels, Args&&... args); - - TLabels CommonLabels_; - }; + template <typename TMetric, EMetricType type, typename TLabelsType, typename... Args> + TMetric* Metric(TLabelsType&& labels, Args&&... args); + + TLabels CommonLabels_; + }; void WriteLabels(IMetricConsumer* consumer, const ILabels& labels); -} +} |