diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/monlib/metrics/summary_snapshot.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/monlib/metrics/summary_snapshot.h')
-rw-r--r-- | library/cpp/monlib/metrics/summary_snapshot.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/library/cpp/monlib/metrics/summary_snapshot.h b/library/cpp/monlib/metrics/summary_snapshot.h new file mode 100644 index 0000000000..afcc895fd3 --- /dev/null +++ b/library/cpp/monlib/metrics/summary_snapshot.h @@ -0,0 +1,72 @@ +#pragma once + +#include <util/generic/ptr.h> + +namespace NMonitoring { + + class ISummaryDoubleSnapshot: public TAtomicRefCount<ISummaryDoubleSnapshot> { + public: + virtual ~ISummaryDoubleSnapshot() = default; + + // TODO: write documentation + + virtual ui64 GetCount() const = 0; + + virtual double GetSum() const = 0; + + virtual double GetMin() const = 0; + + virtual double GetMax() const = 0; + + virtual double GetLast() const = 0; + + virtual ui64 MemorySizeBytes() const = 0; + }; + + using ISummaryDoubleSnapshotPtr = TIntrusivePtr<ISummaryDoubleSnapshot>; + + class TSummaryDoubleSnapshot final: public ISummaryDoubleSnapshot { + public: + TSummaryDoubleSnapshot(double sum, double min, double max, double last, ui64 count) + : Sum_(sum) + , Min_(min) + , Max_(max) + , Last_(last) + , Count_(count) + {} + + ui64 GetCount() const noexcept override { + return Count_; + } + + double GetSum() const noexcept override { + return Sum_; + } + + double GetMin() const noexcept override { + return Min_; + } + + double GetMax() const noexcept override { + return Max_; + } + + virtual double GetLast() const noexcept override { + return Last_; + } + + ui64 MemorySizeBytes() const noexcept override { + return sizeof(*this); + } + + private: + double Sum_; + double Min_; + double Max_; + double Last_; + ui64 Count_; + }; + +} + +std::ostream& operator<<(std::ostream& os, const NMonitoring::ISummaryDoubleSnapshot& s); |