summary_snapshot.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #include <util/generic/ptr.h>
  3. namespace NMonitoring {
  4. class ISummaryDoubleSnapshot: public TAtomicRefCount<ISummaryDoubleSnapshot> {
  5. public:
  6. virtual ~ISummaryDoubleSnapshot() = default;
  7. // TODO: write documentation
  8. virtual ui64 GetCount() const = 0;
  9. virtual double GetSum() const = 0;
  10. virtual double GetMin() const = 0;
  11. virtual double GetMax() const = 0;
  12. virtual double GetLast() const = 0;
  13. virtual ui64 MemorySizeBytes() const = 0;
  14. };
  15. using ISummaryDoubleSnapshotPtr = TIntrusivePtr<ISummaryDoubleSnapshot>;
  16. class TSummaryDoubleSnapshot final: public ISummaryDoubleSnapshot {
  17. public:
  18. TSummaryDoubleSnapshot(double sum, double min, double max, double last, ui64 count)
  19. : Sum_(sum)
  20. , Min_(min)
  21. , Max_(max)
  22. , Last_(last)
  23. , Count_(count)
  24. {}
  25. ui64 GetCount() const noexcept override {
  26. return Count_;
  27. }
  28. double GetSum() const noexcept override {
  29. return Sum_;
  30. }
  31. double GetMin() const noexcept override {
  32. return Min_;
  33. }
  34. double GetMax() const noexcept override {
  35. return Max_;
  36. }
  37. virtual double GetLast() const noexcept override {
  38. return Last_;
  39. }
  40. ui64 MemorySizeBytes() const noexcept override {
  41. return sizeof(*this);
  42. }
  43. private:
  44. double Sum_;
  45. double Min_;
  46. double Max_;
  47. double Last_;
  48. ui64 Count_;
  49. };
  50. }
  51. std::ostream& operator<<(std::ostream& os, const NMonitoring::ISummaryDoubleSnapshot& s);