aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/metrics/log_histogram_snapshot.cpp
blob: 1f444f21576ca46552a42c977d6afacfa3ff5c75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "log_histogram_snapshot.h" 
 
#include <util/stream/output.h> 
 
#include <iostream>
 

namespace {

template <typename TStream>
auto& Output(TStream& o, const NMonitoring::TLogHistogramSnapshot& hist) {
    o << TStringBuf("{");

    for (auto i = 0u; i < hist.Count(); ++i) {
        o << hist.UpperBound(i) << TStringBuf(": ") << hist.Bucket(i);
        o << TStringBuf(", ");
    } 
 
    o << TStringBuf("zeros: ") << hist.ZerosCount();
 
    o << TStringBuf("}");

    return o;
} 

} // namespace

std::ostream& operator<<(std::ostream& os, const NMonitoring::TLogHistogramSnapshot& hist) {
    return Output(os, hist);
}

template <>
void Out<NMonitoring::TLogHistogramSnapshot>(IOutputStream& os, const NMonitoring::TLogHistogramSnapshot& hist) {
    Output(os, hist);
}