ToFloatHistogram returns float Prometheus histogram from the remote implementation of float histogram. If the underlying implementation is an integer histogram, a conversion is performed.
()
| 98 | // of float histogram. If the underlying implementation is an integer histogram, a |
| 99 | // conversion is performed. |
| 100 | func (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 | |
| 132 | func spansProtoToSpans(s []BucketSpan) []histogram.Span { |
| 133 | spans := make([]histogram.Span, len(s)) |