Skip to content

Commit f70c6d6

Browse files
committed
test(pyroscope): add simple unscientific benchmark
1 parent dfec83d commit f70c6d6

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

exporter/clickhouseprofileexporter/metrics.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func initMetrics(meter metric.Meter) error {
1717
if otelcolExporterClickhouseProfileFlushTimeMillis, err = meter.Int64Histogram(
1818
fmt.Sprint(prefix, "flush_time_millis"),
1919
metric.WithDescription("Clickhouse profile exporter flush time in millis"),
20+
metric.WithExplicitBucketBoundaries(0, 5, 10, 20, 50, 100, 200, 500, 1000, 5000),
2021
); err != nil {
2122
return err
2223
}

receiver/pyroscopereceiver/metrics.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@ func initMetrics(meter metric.Meter) error {
2626
if otelcolReceiverPyroscopeRequestBodyUncompressedSizeBytes, err = meter.Int64Histogram(
2727
fmt.Sprint(prefix, "request_body_uncompressed_size_bytes"),
2828
metric.WithDescription("Pyroscope receiver uncompressed request body size in bytes"),
29+
metric.WithExplicitBucketBoundaries(0, 1024, 4096, 16384, 32768, 65536, 131072, 262144, 524288, 1048576),
2930
); err != nil {
3031
return err
3132
}
3233
if otelcolReceiverPyroscopeParsedBodyUncompressedSizeBytes, err = meter.Int64Histogram(
3334
fmt.Sprint(prefix, "parsed_body_uncompressed_size_bytes"),
3435
metric.WithDescription("Pyroscope receiver uncompressed parsed body size in bytes"),
36+
metric.WithExplicitBucketBoundaries(0, 1024, 4096, 16384, 32768, 65536, 131072, 262144, 524288, 1048576),
3537
); err != nil {
3638
return err
3739
}
3840
if otelcolReceiverPyroscopeHttpResponseTimeMillis, err = meter.Int64Histogram(
3941
fmt.Sprint(prefix, "http_response_time_millis"),
4042
metric.WithDescription("Pyroscope receiver http response time in millis"),
43+
metric.WithExplicitBucketBoundaries(0, 5, 10, 20, 50, 100, 200, 500, 1000, 5000),
4144
); err != nil {
4245
return err
4346
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package pyroscopereceiver
2+
3+
import (
4+
"fmt"
5+
"path/filepath"
6+
"testing"
7+
)
8+
9+
type request struct {
10+
urlParams map[string]string
11+
jfr string
12+
}
13+
14+
// Benchmarks a running otelcol pyroscope write pipeline (collector and Clickhouse).
15+
// Adjust collectorAddr to bench a your target if needed.
16+
func BenchmarkPyroscopePipeline(b *testing.B) {
17+
dist := []request{
18+
{
19+
urlParams: map[string]string{
20+
"name": "com.example.App{dc=us-east-1,kubernetes_pod_name=app-abcd1234}",
21+
"from": "1700332322",
22+
"until": "1700332329",
23+
"format": "jfr",
24+
"sampleRate": "100",
25+
},
26+
jfr: filepath.Join("testdata", "cortex-dev-01__kafka-0__cpu__0.jfr"),
27+
},
28+
{
29+
urlParams: map[string]string{
30+
"name": "com.example.App{dc=us-east-1,kubernetes_pod_name=app-abcd1234}",
31+
"from": "1700332322",
32+
"until": "1700332329",
33+
"format": "jfr",
34+
},
35+
jfr: filepath.Join("testdata", "memory_alloc_live_example.jfr"),
36+
},
37+
}
38+
collectorAddr := fmt.Sprintf("http://%s%s", defaultHttpAddr, ingestPath)
39+
40+
b.ResetTimer()
41+
for i, j := 0, 0; i < b.N; i++ {
42+
send(collectorAddr, dist[j].urlParams, dist[j].jfr)
43+
j = (j + 1) % len(dist)
44+
}
45+
}

0 commit comments

Comments
 (0)