aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/metrics/metric.h
diff options
context:
space:
mode:
authormsherbakov <msherbakov@yandex-team.ru>2022-02-10 16:49:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:17 +0300
commita0ffafe83b7d6229709a32fa942c71d672ac989c (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/monlib/metrics/metric.h
parentc224a621661ddd69699f9476922eb316607ef57e (diff)
downloadydb-a0ffafe83b7d6229709a32fa942c71d672ac989c.tar.gz
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/metric.h')
-rw-r--r--library/cpp/monlib/metrics/metric.h218
1 files changed, 109 insertions, 109 deletions
diff --git a/library/cpp/monlib/metrics/metric.h b/library/cpp/monlib/metrics/metric.h
index 95c9332e0a..b8ce12d753 100644
--- a/library/cpp/monlib/metrics/metric.h
+++ b/library/cpp/monlib/metrics/metric.h
@@ -20,19 +20,19 @@ namespace NMonitoring {
using IMetricPtr = THolder<IMetric>;
class IGauge: public IMetric {
- public:
+ public:
EMetricType Type() const noexcept final {
return EMetricType::GAUGE;
- }
-
- virtual double Add(double n) noexcept = 0;
- virtual void Set(double n) noexcept = 0;
- virtual double Get() const noexcept = 0;
- virtual void Reset() noexcept {
- Set(0);
- }
- };
-
+ }
+
+ virtual double Add(double n) noexcept = 0;
+ virtual void Set(double n) noexcept = 0;
+ virtual double Get() const noexcept = 0;
+ virtual void Reset() noexcept {
+ Set(0);
+ }
+ };
+
class ILazyGauge: public IMetric {
public:
EMetricType Type() const noexcept final {
@@ -42,27 +42,27 @@ namespace NMonitoring {
};
class IIntGauge: public IMetric {
- public:
+ public:
EMetricType Type() const noexcept final {
return EMetricType::IGAUGE;
- }
-
- virtual i64 Add(i64 n) noexcept = 0;
- virtual i64 Inc() noexcept {
- return Add(1);
- }
-
- virtual i64 Dec() noexcept {
- return Add(-1);
- }
-
- virtual void Set(i64 value) noexcept = 0;
- virtual i64 Get() const noexcept = 0;
- virtual void Reset() noexcept {
- Set(0);
- }
- };
-
+ }
+
+ virtual i64 Add(i64 n) noexcept = 0;
+ virtual i64 Inc() noexcept {
+ return Add(1);
+ }
+
+ virtual i64 Dec() noexcept {
+ return Add(-1);
+ }
+
+ virtual void Set(i64 value) noexcept = 0;
+ virtual i64 Get() const noexcept = 0;
+ virtual void Reset() noexcept {
+ Set(0);
+ }
+ };
+
class ILazyIntGauge: public IMetric {
public:
EMetricType Type() const noexcept final {
@@ -73,20 +73,20 @@ namespace NMonitoring {
};
class ICounter: public IMetric {
- public:
+ public:
EMetricType Type() const noexcept final {
return EMetricType::COUNTER;
- }
-
- virtual ui64 Inc() noexcept {
- return Add(1);
- }
-
- virtual ui64 Add(ui64 n) noexcept = 0;
- virtual ui64 Get() const noexcept = 0;
- virtual void Reset() noexcept = 0;
- };
-
+ }
+
+ virtual ui64 Inc() noexcept {
+ return Add(1);
+ }
+
+ virtual ui64 Add(ui64 n) noexcept = 0;
+ virtual ui64 Get() const noexcept = 0;
+ virtual void Reset() noexcept = 0;
+ };
+
class ILazyCounter: public IMetric {
public:
EMetricType Type() const noexcept final {
@@ -97,20 +97,20 @@ namespace NMonitoring {
};
class IRate: public IMetric {
- public:
+ public:
EMetricType Type() const noexcept final {
return EMetricType::RATE;
- }
-
- virtual ui64 Inc() noexcept {
- return Add(1);
- }
-
- virtual ui64 Add(ui64 n) noexcept = 0;
- virtual ui64 Get() const noexcept = 0;
+ }
+
+ virtual ui64 Inc() noexcept {
+ return Add(1);
+ }
+
+ virtual ui64 Add(ui64 n) noexcept = 0;
+ virtual ui64 Get() const noexcept = 0;
virtual void Reset() noexcept = 0;
- };
-
+ };
+
class ILazyRate: public IMetric {
public:
EMetricType Type() const noexcept final {
@@ -121,51 +121,51 @@ namespace NMonitoring {
};
class IHistogram: public IMetric {
- public:
- explicit IHistogram(bool isRate)
- : IsRate_{isRate}
- {
- }
-
+ public:
+ explicit IHistogram(bool isRate)
+ : IsRate_{isRate}
+ {
+ }
+
EMetricType Type() const noexcept final {
return IsRate_ ? EMetricType::HIST_RATE : EMetricType::HIST;
- }
-
+ }
+
virtual void Record(double value) = 0;
virtual void Record(double value, ui32 count) = 0;
- virtual IHistogramSnapshotPtr TakeSnapshot() const = 0;
- virtual void Reset() = 0;
-
- protected:
- const bool IsRate_;
- };
-
+ virtual IHistogramSnapshotPtr TakeSnapshot() const = 0;
+ virtual void Reset() = 0;
+
+ protected:
+ const bool IsRate_;
+ };
+
///////////////////////////////////////////////////////////////////////////////
// TGauge
///////////////////////////////////////////////////////////////////////////////
- class TGauge final: public IGauge {
+ class TGauge final: public IGauge {
public:
explicit TGauge(double value = 0.0) {
Set(value);
}
- double Add(double n) noexcept override {
- double newValue;
- double oldValue = Get();
+ double Add(double n) noexcept override {
+ double newValue;
+ double oldValue = Get();
do {
- newValue = oldValue + n;
- } while (!Value_.compare_exchange_weak(oldValue, newValue, std::memory_order_release, std::memory_order_consume));
+ newValue = oldValue + n;
+ } while (!Value_.compare_exchange_weak(oldValue, newValue, std::memory_order_release, std::memory_order_consume));
- return newValue;
+ return newValue;
}
- void Set(double n) noexcept override {
- Value_.store(n, std::memory_order_relaxed);
+ void Set(double n) noexcept override {
+ Value_.store(n, std::memory_order_relaxed);
}
- double Get() const noexcept override {
- return Value_.load(std::memory_order_relaxed);
+ double Get() const noexcept override {
+ return Value_.load(std::memory_order_relaxed);
}
void Accept(TInstant time, IMetricConsumer* consumer) const override {
@@ -173,7 +173,7 @@ namespace NMonitoring {
}
private:
- std::atomic<double> Value_;
+ std::atomic<double> Value_;
};
///////////////////////////////////////////////////////////////////////////////
@@ -201,22 +201,22 @@ namespace NMonitoring {
///////////////////////////////////////////////////////////////////////////////
// TIntGauge
///////////////////////////////////////////////////////////////////////////////
- class TIntGauge final: public IIntGauge {
+ class TIntGauge final: public IIntGauge {
public:
explicit TIntGauge(i64 value = 0) {
Set(value);
}
- i64 Add(i64 n) noexcept override {
- return Value_.fetch_add(n, std::memory_order_relaxed) + n;
+ i64 Add(i64 n) noexcept override {
+ return Value_.fetch_add(n, std::memory_order_relaxed) + n;
}
- void Set(i64 value) noexcept override {
- Value_.store(value, std::memory_order_relaxed);
+ void Set(i64 value) noexcept override {
+ Value_.store(value, std::memory_order_relaxed);
}
- i64 Get() const noexcept override {
- return Value_.load(std::memory_order_relaxed);
+ i64 Get() const noexcept override {
+ return Value_.load(std::memory_order_relaxed);
}
void Accept(TInstant time, IMetricConsumer* consumer) const override {
@@ -224,7 +224,7 @@ namespace NMonitoring {
}
private:
- std::atomic_int64_t Value_;
+ std::atomic_int64_t Value_;
};
///////////////////////////////////////////////////////////////////////////////
@@ -255,19 +255,19 @@ namespace NMonitoring {
class TCounter final: public ICounter {
public:
explicit TCounter(ui64 value = 0) {
- Value_.store(value, std::memory_order_relaxed);
+ Value_.store(value, std::memory_order_relaxed);
}
- ui64 Add(ui64 n) noexcept override {
- return Value_.fetch_add(n, std::memory_order_relaxed) + n;
+ ui64 Add(ui64 n) noexcept override {
+ return Value_.fetch_add(n, std::memory_order_relaxed) + n;
}
- ui64 Get() const noexcept override {
- return Value_.load(std::memory_order_relaxed);
+ ui64 Get() const noexcept override {
+ return Value_.load(std::memory_order_relaxed);
}
- void Reset() noexcept override {
- Value_.store(0, std::memory_order_relaxed);
+ void Reset() noexcept override {
+ Value_.store(0, std::memory_order_relaxed);
}
void Accept(TInstant time, IMetricConsumer* consumer) const override {
@@ -275,7 +275,7 @@ namespace NMonitoring {
}
private:
- std::atomic_uint64_t Value_;
+ std::atomic_uint64_t Value_;
};
///////////////////////////////////////////////////////////////////////////////
@@ -303,18 +303,18 @@ namespace NMonitoring {
///////////////////////////////////////////////////////////////////////////////
// TRate
///////////////////////////////////////////////////////////////////////////////
- class TRate final: public IRate {
+ class TRate final: public IRate {
public:
explicit TRate(ui64 value = 0) {
- Value_.store(value, std::memory_order_relaxed);
+ Value_.store(value, std::memory_order_relaxed);
}
- ui64 Add(ui64 n) noexcept override {
- return Value_.fetch_add(n, std::memory_order_relaxed) + n;
+ ui64 Add(ui64 n) noexcept override {
+ return Value_.fetch_add(n, std::memory_order_relaxed) + n;
}
- ui64 Get() const noexcept override {
- return Value_.load(std::memory_order_relaxed);
+ ui64 Get() const noexcept override {
+ return Value_.load(std::memory_order_relaxed);
}
void Reset() noexcept override {
@@ -326,7 +326,7 @@ namespace NMonitoring {
}
private:
- std::atomic_uint64_t Value_;
+ std::atomic_uint64_t Value_;
};
///////////////////////////////////////////////////////////////////////////////
@@ -354,11 +354,11 @@ namespace NMonitoring {
///////////////////////////////////////////////////////////////////////////////
// THistogram
///////////////////////////////////////////////////////////////////////////////
- class THistogram final: public IHistogram {
+ class THistogram final: public IHistogram {
public:
THistogram(IHistogramCollectorPtr collector, bool isRate)
- : IHistogram(isRate)
- , Collector_(std::move(collector))
+ : IHistogram(isRate)
+ , Collector_(std::move(collector))
{
}
@@ -374,14 +374,14 @@ namespace NMonitoring {
consumer->OnHistogram(time, TakeSnapshot());
}
- IHistogramSnapshotPtr TakeSnapshot() const override {
+ IHistogramSnapshotPtr TakeSnapshot() const override {
return Collector_->Snapshot();
}
- void Reset() override {
+ void Reset() override {
Collector_->Reset();
}
-
+
private:
IHistogramCollectorPtr Collector_;
};