log_histogram_snapshot.cpp 780 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "log_histogram_snapshot.h"
  2. #include <util/stream/output.h>
  3. #include <iostream>
  4. namespace {
  5. template <typename TStream>
  6. auto& Output(TStream& o, const NMonitoring::TLogHistogramSnapshot& hist) {
  7. o << TStringBuf("{");
  8. for (auto i = 0u; i < hist.Count(); ++i) {
  9. o << hist.UpperBound(i) << TStringBuf(": ") << hist.Bucket(i);
  10. o << TStringBuf(", ");
  11. }
  12. o << TStringBuf("zeros: ") << hist.ZerosCount();
  13. o << TStringBuf("}");
  14. return o;
  15. }
  16. } // namespace
  17. std::ostream& operator<<(std::ostream& os, const NMonitoring::TLogHistogramSnapshot& hist) {
  18. return Output(os, hist);
  19. }
  20. template <>
  21. void Out<NMonitoring::TLogHistogramSnapshot>(IOutputStream& os, const NMonitoring::TLogHistogramSnapshot& hist) {
  22. Output(os, hist);
  23. }