aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/counters/histogram.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/monlib/counters/histogram.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/monlib/counters/histogram.cpp')
-rw-r--r--library/cpp/monlib/counters/histogram.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/library/cpp/monlib/counters/histogram.cpp b/library/cpp/monlib/counters/histogram.cpp
new file mode 100644
index 0000000000..46cf4e6ec8
--- /dev/null
+++ b/library/cpp/monlib/counters/histogram.cpp
@@ -0,0 +1,40 @@
+#include "histogram.h"
+
+namespace NMonitoring {
+ void THistogramSnapshot::Print(IOutputStream* out) const {
+ (*out) << "mean: " << Mean
+ << ", stddev: " << StdDeviation
+ << ", min: " << Min
+ << ", max: " << Max
+ << ", 50%: " << Percentile50
+ << ", 75%: " << Percentile75
+ << ", 90%: " << Percentile90
+ << ", 95%: " << Percentile95
+ << ", 98%: " << Percentile98
+ << ", 99%: " << Percentile99
+ << ", 99.9%: " << Percentile999
+ << ", count: " << TotalCount;
+ }
+
+ void THdrHistogram::TakeSnaphot(THistogramSnapshot* snapshot) {
+ with_lock (Lock_) {
+ // TODO: get data with single traverse
+ snapshot->Mean = Data_.GetMean();
+ snapshot->StdDeviation = Data_.GetStdDeviation();
+ snapshot->Min = Data_.GetMin();
+ snapshot->Max = Data_.GetMax();
+ snapshot->Percentile50 = Data_.GetValueAtPercentile(50.0);
+ snapshot->Percentile75 = Data_.GetValueAtPercentile(75.0);
+ snapshot->Percentile90 = Data_.GetValueAtPercentile(90.0);
+ snapshot->Percentile95 = Data_.GetValueAtPercentile(95.0);
+ snapshot->Percentile98 = Data_.GetValueAtPercentile(98.0);
+ snapshot->Percentile99 = Data_.GetValueAtPercentile(99.0);
+ snapshot->Percentile999 = Data_.GetValueAtPercentile(99.9);
+ snapshot->TotalCount = Data_.GetTotalCount();
+
+ // cleanup histogram data
+ Data_.Reset();
+ }
+ }
+
+}