MCPcopy
hub / github.com/prometheus/prometheus / ToFloatHistogram

Method ToFloatHistogram

prompb/codec.go:100–130  ·  view source on GitHub ↗

ToFloatHistogram returns float Prometheus histogram from the remote implementation of float histogram. If the underlying implementation is an integer histogram, a conversion is performed.

()

Source from the content-addressed store, hash-verified

98// of float histogram. If the underlying implementation is an integer histogram, a
99// conversion is performed.
100func (h Histogram) ToFloatHistogram() *histogram.FloatHistogram {
101 if h.IsFloatHistogram() {
102 return &histogram.FloatHistogram{
103 CounterResetHint: histogram.CounterResetHint(h.ResetHint),
104 Schema: h.Schema,
105 ZeroThreshold: h.ZeroThreshold,
106 ZeroCount: h.GetZeroCountFloat(),
107 Count: h.GetCountFloat(),
108 Sum: h.Sum,
109 PositiveSpans: spansProtoToSpans(h.GetPositiveSpans()),
110 PositiveBuckets: h.GetPositiveCounts(),
111 NegativeSpans: spansProtoToSpans(h.GetNegativeSpans()),
112 NegativeBuckets: h.GetNegativeCounts(),
113 CustomValues: h.CustomValues, // CustomValues are immutable.
114 }
115 }
116 // Conversion from integer histogram.
117 return &histogram.FloatHistogram{
118 CounterResetHint: histogram.CounterResetHint(h.ResetHint),
119 Schema: h.Schema,
120 ZeroThreshold: h.ZeroThreshold,
121 ZeroCount: float64(h.GetZeroCountInt()),
122 Count: float64(h.GetCountInt()),
123 Sum: h.Sum,
124 PositiveSpans: spansProtoToSpans(h.GetPositiveSpans()),
125 PositiveBuckets: deltasToCounts(h.GetPositiveDeltas()),
126 NegativeSpans: spansProtoToSpans(h.GetNegativeSpans()),
127 NegativeBuckets: deltasToCounts(h.GetNegativeDeltas()),
128 CustomValues: h.CustomValues, // CustomValues are immutable.
129 }
130}
131
132func spansProtoToSpans(s []BucketSpan) []histogram.Span {
133 spans := make([]histogram.Span, len(s))

Callers 11

printV1Function · 0.45
printV2Function · 0.45
setCurrentHistogramMethod · 0.45
appendV1HistogramsMethod · 0.45
appendV2Method · 0.45
v2RequestToWriteRequestFunction · 0.45

Calls 14

IsFloatHistogramMethod · 0.95
GetZeroCountFloatMethod · 0.95
GetCountFloatMethod · 0.95
GetPositiveSpansMethod · 0.95
GetPositiveCountsMethod · 0.95
GetNegativeSpansMethod · 0.95
GetNegativeCountsMethod · 0.95
GetZeroCountIntMethod · 0.95
GetCountIntMethod · 0.95
GetPositiveDeltasMethod · 0.95
GetNegativeDeltasMethod · 0.95
CounterResetHintTypeAlias · 0.92