MCPcopy Create free account
hub / github.com/cortexproject/cortex / HistogramPromProtoToHistogramProto

Function HistogramPromProtoToHistogramProto

pkg/cortexpb/histograms.go:29–52  ·  view source on GitHub ↗

HistogramPromProtoToHistogramProto converts a prometheus protobuf Histogram to cortex protobuf Histogram.

(h prompb.Histogram)

Source from the content-addressed store, hash-verified

27
28// HistogramPromProtoToHistogramProto converts a prometheus protobuf Histogram to cortex protobuf Histogram.
29func 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

Callers 1

makeHistogramsFunction · 0.92

Calls 7

Histogram_ResetHintTypeAlias · 0.85
IsFloatHistogramMethod · 0.80
GetCountFloatMethod · 0.80
GetZeroCountFloatMethod · 0.80
GetCountIntMethod · 0.80
GetZeroCountIntMethod · 0.80

Tested by

no test coverage detected