aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/metrics/ewma.h
diff options
context:
space:
mode:
authormsherbakov <msherbakov@yandex-team.ru>2022-02-10 16:49:16 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:16 +0300
commitc224a621661ddd69699f9476922eb316607ef57e (patch)
tree33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/monlib/metrics/ewma.h
parent29d0b2eeae154d04156e0698067c0c21a97ea61d (diff)
downloadydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/ewma.h')
-rw-r--r--library/cpp/monlib/metrics/ewma.h94
1 files changed, 47 insertions, 47 deletions
diff --git a/library/cpp/monlib/metrics/ewma.h b/library/cpp/monlib/metrics/ewma.h
index 9b2dad7cc5..06a2bc5058 100644
--- a/library/cpp/monlib/metrics/ewma.h
+++ b/library/cpp/monlib/metrics/ewma.h
@@ -1,47 +1,47 @@
-#pragma once
-
-#include <util/datetime/base.h>
-#include <util/generic/ptr.h>
-
-#include <atomic>
-
-namespace NMonitoring {
- class IGauge;
-
- class IExpMovingAverage {
- public:
- virtual ~IExpMovingAverage() = default;
- virtual void Tick() = 0;
- virtual void Update(i64 value) = 0;
- virtual double Rate() const = 0;
- virtual void Reset() = 0;
- };
-
- using IExpMovingAveragePtr = THolder<IExpMovingAverage>;
-
- class TEwmaMeter {
- public:
- // Creates a fake EWMA that will always return 0. Mostly for usage convenience
- TEwmaMeter();
- explicit TEwmaMeter(IExpMovingAveragePtr&& ewma);
-
- TEwmaMeter(TEwmaMeter&& other);
- TEwmaMeter& operator=(TEwmaMeter&& other);
-
- void Mark();
- void Mark(i64 value);
-
- double Get();
-
- private:
- void TickIfNeeded();
-
- private:
- IExpMovingAveragePtr Ewma_;
- std::atomic<ui64> LastTick_{TInstant::Now().Seconds()};
- };
-
- IExpMovingAveragePtr OneMinuteEwma(IGauge* gauge);
- IExpMovingAveragePtr FiveMinuteEwma(IGauge* gauge);
- IExpMovingAveragePtr FiveteenMinuteEwma(IGauge* gauge);
-} // namespace NMonitoring
+#pragma once
+
+#include <util/datetime/base.h>
+#include <util/generic/ptr.h>
+
+#include <atomic>
+
+namespace NMonitoring {
+ class IGauge;
+
+ class IExpMovingAverage {
+ public:
+ virtual ~IExpMovingAverage() = default;
+ virtual void Tick() = 0;
+ virtual void Update(i64 value) = 0;
+ virtual double Rate() const = 0;
+ virtual void Reset() = 0;
+ };
+
+ using IExpMovingAveragePtr = THolder<IExpMovingAverage>;
+
+ class TEwmaMeter {
+ public:
+ // Creates a fake EWMA that will always return 0. Mostly for usage convenience
+ TEwmaMeter();
+ explicit TEwmaMeter(IExpMovingAveragePtr&& ewma);
+
+ TEwmaMeter(TEwmaMeter&& other);
+ TEwmaMeter& operator=(TEwmaMeter&& other);
+
+ void Mark();
+ void Mark(i64 value);
+
+ double Get();
+
+ private:
+ void TickIfNeeded();
+
+ private:
+ IExpMovingAveragePtr Ewma_;
+ std::atomic<ui64> LastTick_{TInstant::Now().Seconds()};
+ };
+
+ IExpMovingAveragePtr OneMinuteEwma(IGauge* gauge);
+ IExpMovingAveragePtr FiveMinuteEwma(IGauge* gauge);
+ IExpMovingAveragePtr FiveteenMinuteEwma(IGauge* gauge);
+} // namespace NMonitoring