blob: 7673b43751e7f32f5bffcfdf9b455a75a85470a3 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#pragma once
#include <util/generic/ptr.h>
#include <util/generic/vector.h>
#include <cmath>
namespace NMonitoring {
constexpr ui32 LOG_HIST_MAX_BUCKETS = 100;
class TLogHistogramSnapshot: public TAtomicRefCount<TLogHistogramSnapshot> {
public:
TLogHistogramSnapshot(double base, ui64 zerosCount, int startPower, TVector<double> buckets)
: Base_(base)
, ZerosCount_(zerosCount)
, StartPower_(startPower)
, Buckets_(std::move(buckets)) {
}
/**
* @return buckets count.
*/
ui32 Count() const noexcept {
return Buckets_.size();
}
/**
* @return upper bound for the bucket with particular index.
*/
double UpperBound(int index) const noexcept {
return std::pow(Base_, StartPower_ + index);
}
/**
* @return value stored in the bucket with particular index.
*/
double Bucket(ui32 index) const noexcept {
return Buckets_[index];
}
/**
* @return nonpositive values count
*/
ui64 ZerosCount() const noexcept {
return ZerosCount_;
}
double Base() const noexcept {
return Base_;
}
int StartPower() const noexcept {
return StartPower_;
}
ui64 MemorySizeBytes() const noexcept {
return sizeof(*this) + Buckets_.capacity() * sizeof(double);
}
private:
double Base_;
ui64 ZerosCount_;
int StartPower_;
TVector<double> Buckets_;
};
using TLogHistogramSnapshotPtr = TIntrusivePtr<TLogHistogramSnapshot>;
}
std::ostream& operator<<(std::ostream& os, const NMonitoring::TLogHistogramSnapshot& hist);
|