mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Export histogramToHistogramProto()
(#11046)
Signed-off-by: Levi Harrison <git@leviharrison.dev>
This commit is contained in:
parent
7feea8aa89
commit
0db6b072bc
|
@ -528,7 +528,7 @@ func spansProtoToSpans(s []*prompb.BucketSpan) []histogram.Span {
|
|||
return spans
|
||||
}
|
||||
|
||||
func histogramToHistogramProto(timestamp int64, h *histogram.Histogram) prompb.Histogram {
|
||||
func HistogramToHistogramProto(timestamp int64, h *histogram.Histogram) prompb.Histogram {
|
||||
return prompb.Histogram{
|
||||
Count: &prompb.Histogram_CountInt{CountInt: h.Count},
|
||||
Sum: h.Sum,
|
||||
|
|
|
@ -52,7 +52,7 @@ var writeRequestFixture = &prompb.WriteRequest{
|
|||
},
|
||||
Samples: []prompb.Sample{{Value: 1, Timestamp: 0}},
|
||||
Exemplars: []prompb.Exemplar{{Labels: []prompb.Label{{Name: "f", Value: "g"}}, Value: 1, Timestamp: 0}},
|
||||
Histograms: []prompb.Histogram{histogramToHistogramProto(0, &testHistogram)},
|
||||
Histograms: []prompb.Histogram{HistogramToHistogramProto(0, &testHistogram)},
|
||||
},
|
||||
{
|
||||
Labels: []prompb.Label{
|
||||
|
@ -64,7 +64,7 @@ var writeRequestFixture = &prompb.WriteRequest{
|
|||
},
|
||||
Samples: []prompb.Sample{{Value: 2, Timestamp: 1}},
|
||||
Exemplars: []prompb.Exemplar{{Labels: []prompb.Label{{Name: "h", Value: "i"}}, Value: 2, Timestamp: 1}},
|
||||
Histograms: []prompb.Histogram{histogramToHistogramProto(1, &testHistogram)},
|
||||
Histograms: []prompb.Histogram{HistogramToHistogramProto(1, &testHistogram)},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1397,7 +1397,7 @@ func (s *shards) populateTimeSeries(batch []timeSeries, pendingData []prompb.Tim
|
|||
})
|
||||
nPendingExemplars++
|
||||
case tHistogram:
|
||||
pendingData[nPending].Histograms = append(pendingData[nPending].Histograms, histogramToHistogramProto(d.timestamp, d.histogram))
|
||||
pendingData[nPending].Histograms = append(pendingData[nPending].Histograms, HistogramToHistogramProto(d.timestamp, d.histogram))
|
||||
nPendingHistograms++
|
||||
}
|
||||
}
|
||||
|
|
|
@ -701,7 +701,7 @@ func (c *TestWriteClient) expectHistograms(hh []record.RefHistogram, series []re
|
|||
|
||||
for _, h := range hh {
|
||||
seriesName := getSeriesNameFromRef(series[h.Ref])
|
||||
c.expectedHistograms[seriesName] = append(c.expectedHistograms[seriesName], histogramToHistogramProto(h.T, h.H))
|
||||
c.expectedHistograms[seriesName] = append(c.expectedHistograms[seriesName], HistogramToHistogramProto(h.T, h.H))
|
||||
}
|
||||
c.wg.Add(len(hh))
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ func TestOutOfOrderExemplar(t *testing.T) {
|
|||
func TestOutOfOrderHistogram(t *testing.T) {
|
||||
buf, _, err := buildWriteRequest([]prompb.TimeSeries{{
|
||||
Labels: []prompb.Label{{Name: "__name__", Value: "test_metric"}},
|
||||
Histograms: []prompb.Histogram{histogramToHistogramProto(0, &testHistogram)},
|
||||
Histograms: []prompb.Histogram{HistogramToHistogramProto(0, &testHistogram)},
|
||||
}}, nil, nil, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Reference in a new issue