diff options
author | ivanzhukov <ivanzhukov@yandex-team.ru> | 2022-02-10 16:49:41 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:41 +0300 |
commit | ca3252a147a429eac4ba8221857493c58dcd09b5 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/monlib/metrics/histogram_snapshot.cpp | |
parent | 0892d79ab411592ad25175c4bdadbcb09b466cf5 (diff) | |
download | ydb-ca3252a147a429eac4ba8221857493c58dcd09b5.tar.gz |
Restoring authorship annotation for <ivanzhukov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/histogram_snapshot.cpp')
-rw-r--r-- | library/cpp/monlib/metrics/histogram_snapshot.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/monlib/metrics/histogram_snapshot.cpp b/library/cpp/monlib/metrics/histogram_snapshot.cpp index 1d6cb90c37..75b5811546 100644 --- a/library/cpp/monlib/metrics/histogram_snapshot.cpp +++ b/library/cpp/monlib/metrics/histogram_snapshot.cpp @@ -2,62 +2,62 @@ #include <util/stream/output.h> -#include <iostream> - - +#include <iostream> + + namespace NMonitoring { IHistogramSnapshotPtr ExplicitHistogramSnapshot(TConstArrayRef<TBucketBound> bounds, TConstArrayRef<TBucketValue> values) { - Y_ENSURE(bounds.size() == values.size(), - "mismatched sizes: bounds(" << bounds.size() << - ") != buckets(" << values.size() << ')'); + Y_ENSURE(bounds.size() == values.size(), + "mismatched sizes: bounds(" << bounds.size() << + ") != buckets(" << values.size() << ')'); - auto snapshot = TExplicitHistogramSnapshot::New(bounds.size()); + auto snapshot = TExplicitHistogramSnapshot::New(bounds.size()); - for (size_t i = 0; i != bounds.size(); ++i) { - (*snapshot)[i].first = bounds[i]; - (*snapshot)[i].second = values[i]; - } + for (size_t i = 0; i != bounds.size(); ++i) { + (*snapshot)[i].first = bounds[i]; + (*snapshot)[i].second = values[i]; + } - return snapshot; + return snapshot; } -} // namespace NMonitoring +} // namespace NMonitoring -namespace { +namespace { -template <typename TStream> -auto& Output(TStream& os, const NMonitoring::IHistogramSnapshot& hist) { +template <typename TStream> +auto& Output(TStream& os, const NMonitoring::IHistogramSnapshot& hist) { os << TStringBuf("{"); - ui32 i = 0; - ui32 count = hist.Count(); + ui32 i = 0; + ui32 count = hist.Count(); - if (count > 0) { - for (; i < count - 1; ++i) { + if (count > 0) { + for (; i < count - 1; ++i) { os << hist.UpperBound(i) << TStringBuf(": ") << hist.Value(i); os << TStringBuf(", "); - } - - if (hist.UpperBound(i) == Max<NMonitoring::TBucketBound>()) { + } + + if (hist.UpperBound(i) == Max<NMonitoring::TBucketBound>()) { os << TStringBuf("inf: ") << hist.Value(i); - } else { + } else { os << hist.UpperBound(i) << TStringBuf(": ") << hist.Value(i); - } + } } os << TStringBuf("}"); - - return os; + + return os; +} + +} // namespace + +std::ostream& operator<<(std::ostream& os, const NMonitoring::IHistogramSnapshot& hist) { + return Output(os, hist); +} + +template <> +void Out<NMonitoring::IHistogramSnapshot>(IOutputStream& os, const NMonitoring::IHistogramSnapshot& hist) { + Output(os, hist); } - -} // namespace - -std::ostream& operator<<(std::ostream& os, const NMonitoring::IHistogramSnapshot& hist) { - return Output(os, hist); -} - -template <> -void Out<NMonitoring::IHistogramSnapshot>(IOutputStream& os, const NMonitoring::IHistogramSnapshot& hist) { - Output(os, hist); -} |