Skip to content

Commit

Permalink
add metadata and histograms to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
edma2 committed Nov 5, 2024
1 parent 51272b1 commit f2b6aac
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions exporter/prometheusremotewriteexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,17 +1214,51 @@ func benchmarkExecute(b *testing.B, numSample int) {
return samples
}

generateHistograms := func(n int) []prompb.Histogram {
histograms := make([]prompb.Histogram, 0, n)
for i := 0; i < n; i++ {
histograms = append(histograms, prompb.Histogram{
Timestamp: int64(i),
Count: &prompb.Histogram_CountInt{CountInt: uint64(i)},
PositiveCounts: []float64{float64(i)},
})
}
return histograms
}

reqs := make([]*prompb.WriteRequest, 0, b.N)
const labelValue = "abcdefg'hijlmn234!@#$%^&*()_+~`\"{}[],./<>?hello0123hiOlá你好Dzieńdobry9Zd8ra765v4stvuyte"
for n := 0; n < b.N; n++ {
num := strings.Repeat(strconv.Itoa(n), 16)
req := &prompb.WriteRequest{
Timeseries: []prompb.TimeSeries{{
Samples: generateSamples(numSample),
Labels: []prompb.Label{
{Name: "__name__", Value: "test_metric"},
{Name: "test_label_name_" + num, Value: labelValue + num},
}}},
Metadata: []prompb.MetricMetadata{
{
Type: prompb.MetricMetadata_COUNTER,
Unit: "seconds",
Help: "This is a counter",
},
{
Type: prompb.MetricMetadata_HISTOGRAM,
Unit: "seconds",
Help: "This is a histogram",
},
},
Timeseries: []prompb.TimeSeries{
{
Samples: generateSamples(numSample),
Labels: []prompb.Label{
{Name: "__name__", Value: "test_metric"},
{Name: "test_label_name_" + num, Value: labelValue + num},
},
},
{
Histograms: generateHistograms(numSample),
Labels: []prompb.Label{
{Name: "__name__", Value: "test_histogram"},
{Name: "test_label_name_" + num, Value: labelValue + num},
},
},
},
}
reqs = append(reqs, req)
}
Expand Down

0 comments on commit f2b6aac

Please sign in to comment.