|
|
@ -19,6 +19,17 @@ import ( |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CounterResetHint contains the known information about a counter reset,
|
|
|
|
|
|
|
|
// or alternatively that we are dealing with a gauge histogram, where counter resets do not apply.
|
|
|
|
|
|
|
|
type CounterResetHint byte |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
|
|
UnknownCounterReset CounterResetHint = iota // UnknownCounterReset means we cannot say if this histogram signals a counter reset or not.
|
|
|
|
|
|
|
|
CounterReset // CounterReset means there was definitely a counter reset starting from this histogram.
|
|
|
|
|
|
|
|
NotCounterReset // NotCounterReset means there was definitely no counter reset with this histogram.
|
|
|
|
|
|
|
|
GaugeType // GaugeType means this is a gauge histogram, where counter resets do not happen.
|
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Histogram encodes a sparse, high-resolution histogram. See the design
|
|
|
|
// Histogram encodes a sparse, high-resolution histogram. See the design
|
|
|
|
// document for full details:
|
|
|
|
// document for full details:
|
|
|
|
// https://docs.google.com/document/d/1cLNv3aufPZb3fNfaJgdaRBZsInZKKIHo9E6HinJVbpM/edit#
|
|
|
|
// https://docs.google.com/document/d/1cLNv3aufPZb3fNfaJgdaRBZsInZKKIHo9E6HinJVbpM/edit#
|
|
|
@ -35,6 +46,8 @@ import ( |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Which bucket indices are actually used is determined by the spans.
|
|
|
|
// Which bucket indices are actually used is determined by the spans.
|
|
|
|
type Histogram struct { |
|
|
|
type Histogram struct { |
|
|
|
|
|
|
|
// Counter reset information.
|
|
|
|
|
|
|
|
CounterResetHint CounterResetHint |
|
|
|
// Currently valid schema numbers are -4 <= n <= 8. They are all for
|
|
|
|
// Currently valid schema numbers are -4 <= n <= 8. They are all for
|
|
|
|
// base-2 bucket schemas, where 1 is a bucket boundary in each case, and
|
|
|
|
// base-2 bucket schemas, where 1 is a bucket boundary in each case, and
|
|
|
|
// then each power of two is divided into 2^n logarithmic buckets. Or
|
|
|
|
// then each power of two is divided into 2^n logarithmic buckets. Or
|
|
|
@ -295,15 +308,16 @@ func (h *Histogram) ToFloat() *FloatHistogram { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return &FloatHistogram{ |
|
|
|
return &FloatHistogram{ |
|
|
|
Schema: h.Schema, |
|
|
|
CounterResetHint: h.CounterResetHint, |
|
|
|
ZeroThreshold: h.ZeroThreshold, |
|
|
|
Schema: h.Schema, |
|
|
|
ZeroCount: float64(h.ZeroCount), |
|
|
|
ZeroThreshold: h.ZeroThreshold, |
|
|
|
Count: float64(h.Count), |
|
|
|
ZeroCount: float64(h.ZeroCount), |
|
|
|
Sum: h.Sum, |
|
|
|
Count: float64(h.Count), |
|
|
|
PositiveSpans: positiveSpans, |
|
|
|
Sum: h.Sum, |
|
|
|
NegativeSpans: negativeSpans, |
|
|
|
PositiveSpans: positiveSpans, |
|
|
|
PositiveBuckets: positiveBuckets, |
|
|
|
NegativeSpans: negativeSpans, |
|
|
|
NegativeBuckets: negativeBuckets, |
|
|
|
PositiveBuckets: positiveBuckets, |
|
|
|
|
|
|
|
NegativeBuckets: negativeBuckets, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|