HistogramPromProtoToHistogramProto converts a prometheus protobuf Histogram to cortex protobuf Histogram.
(h prompb.Histogram)
| 27 | |
| 28 | // HistogramPromProtoToHistogramProto converts a prometheus protobuf Histogram to cortex protobuf Histogram. |
| 29 | func HistogramPromProtoToHistogramProto(h prompb.Histogram) Histogram { |
| 30 | ph := Histogram{ |
| 31 | Sum: h.Sum, |
| 32 | Schema: h.Schema, |
| 33 | ZeroThreshold: h.ZeroThreshold, |
| 34 | NegativeSpans: spansPromProtoToSpansProto(h.NegativeSpans), |
| 35 | NegativeDeltas: h.NegativeDeltas, |
| 36 | NegativeCounts: h.NegativeCounts, |
| 37 | PositiveSpans: spansPromProtoToSpansProto(h.PositiveSpans), |
| 38 | PositiveDeltas: h.PositiveDeltas, |
| 39 | PositiveCounts: h.PositiveCounts, |
| 40 | ResetHint: Histogram_ResetHint(h.ResetHint), |
| 41 | TimestampMs: h.Timestamp, |
| 42 | CustomValues: h.CustomValues, |
| 43 | } |
| 44 | if h.IsFloatHistogram() { |
| 45 | ph.Count = &Histogram_CountFloat{CountFloat: h.GetCountFloat()} |
| 46 | ph.ZeroCount = &Histogram_ZeroCountFloat{ZeroCountFloat: h.GetZeroCountFloat()} |
| 47 | } else { |
| 48 | ph.Count = &Histogram_CountInt{CountInt: h.GetCountInt()} |
| 49 | ph.ZeroCount = &Histogram_ZeroCountInt{ZeroCountInt: h.GetZeroCountInt()} |
| 50 | } |
| 51 | return ph |
| 52 | } |
| 53 | |
| 54 | // HistogramProtoToHistogram extracts a (normal integer) Histogram from the |
| 55 | // provided proto message. The caller has to make sure that the proto message |
no test coverage detected