diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:02 +0300 |
commit | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch) | |
tree | c2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/monlib/metrics/ewma.cpp | |
parent | ab3783171cc30e262243a0227c86118f7080c896 (diff) | |
download | ydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/ewma.cpp')
-rw-r--r-- | library/cpp/monlib/metrics/ewma.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/library/cpp/monlib/metrics/ewma.cpp b/library/cpp/monlib/metrics/ewma.cpp index 8a296c3225..4ee78c0c3d 100644 --- a/library/cpp/monlib/metrics/ewma.cpp +++ b/library/cpp/monlib/metrics/ewma.cpp @@ -1,5 +1,5 @@ #include "ewma.h" -#include "metric.h" +#include "metric.h" #include <atomic> #include <cmath> @@ -14,12 +14,12 @@ namespace { class TExpMovingAverage final: public IExpMovingAverage { public: - explicit TExpMovingAverage(IGauge* metric, double alpha, TDuration interval) - : Metric_{metric} + explicit TExpMovingAverage(IGauge* metric, double alpha, TDuration interval) + : Metric_{metric} , Alpha_{alpha} , Interval_{interval.Seconds()} { - Y_VERIFY(metric != nullptr, "Passing nullptr metric is not allowed"); + Y_VERIFY(metric != nullptr, "Passing nullptr metric is not allowed"); } ~TExpMovingAverage() override = default; @@ -30,11 +30,11 @@ namespace { const double instantRate = double(current) / Interval_; if (Y_UNLIKELY(!IsInitialized())) { - Metric_->Set(instantRate); + Metric_->Set(instantRate); Init_ = true; } else { - const double currentRate = Metric_->Get(); - Metric_->Set(Alpha_ * (instantRate - currentRate) + currentRate); + const double currentRate = Metric_->Get(); + Metric_->Set(Alpha_ * (instantRate - currentRate) + currentRate); } } @@ -44,7 +44,7 @@ namespace { } double Rate() const override { - return Metric_->Get(); + return Metric_->Get(); } void Reset() override { @@ -61,7 +61,7 @@ namespace { std::atomic<i64> Uncounted_{0}; std::atomic<bool> Init_{false}; - IGauge* Metric_{nullptr}; + IGauge* Metric_{nullptr}; double Alpha_; ui64 Interval_; }; @@ -132,19 +132,19 @@ namespace { return Ewma_->Rate(); } - IExpMovingAveragePtr OneMinuteEwma(IGauge* metric) { - return MakeHolder<TExpMovingAverage>(metric, ALPHA1, DEFAULT_INTERVAL); + IExpMovingAveragePtr OneMinuteEwma(IGauge* metric) { + return MakeHolder<TExpMovingAverage>(metric, ALPHA1, DEFAULT_INTERVAL); } - IExpMovingAveragePtr FiveMinuteEwma(IGauge* metric) { - return MakeHolder<TExpMovingAverage>(metric, ALPHA5, DEFAULT_INTERVAL); + IExpMovingAveragePtr FiveMinuteEwma(IGauge* metric) { + return MakeHolder<TExpMovingAverage>(metric, ALPHA5, DEFAULT_INTERVAL); } - IExpMovingAveragePtr FiveteenMinuteEwma(IGauge* metric) { - return MakeHolder<TExpMovingAverage>(metric, ALPHA15, DEFAULT_INTERVAL); + IExpMovingAveragePtr FiveteenMinuteEwma(IGauge* metric) { + return MakeHolder<TExpMovingAverage>(metric, ALPHA15, DEFAULT_INTERVAL); } - IExpMovingAveragePtr CreateEwma(IGauge* metric, double alpha, TDuration interval) { - return MakeHolder<TExpMovingAverage>(metric, alpha, interval); + IExpMovingAveragePtr CreateEwma(IGauge* metric, double alpha, TDuration interval) { + return MakeHolder<TExpMovingAverage>(metric, alpha, interval); } } // namespace NMonitoring |