diff --git a/exporter/clickhouseprofileexporter/metrics.go b/exporter/clickhouseprofileexporter/metrics.go index 37bb392..83082cf 100644 --- a/exporter/clickhouseprofileexporter/metrics.go +++ b/exporter/clickhouseprofileexporter/metrics.go @@ -17,6 +17,7 @@ func initMetrics(meter metric.Meter) error { if otelcolExporterClickhouseProfileFlushTimeMillis, err = meter.Int64Histogram( fmt.Sprint(prefix, "flush_time_millis"), metric.WithDescription("Clickhouse profile exporter flush time in millis"), + metric.WithExplicitBucketBoundaries(0, 5, 10, 20, 50, 100, 200, 500, 1000, 5000), ); err != nil { return err } diff --git a/receiver/pyroscopereceiver/metrics.go b/receiver/pyroscopereceiver/metrics.go index d68f41a..f77d1c9 100644 --- a/receiver/pyroscopereceiver/metrics.go +++ b/receiver/pyroscopereceiver/metrics.go @@ -26,18 +26,21 @@ func initMetrics(meter metric.Meter) error { if otelcolReceiverPyroscopeRequestBodyUncompressedSizeBytes, err = meter.Int64Histogram( fmt.Sprint(prefix, "request_body_uncompressed_size_bytes"), metric.WithDescription("Pyroscope receiver uncompressed request body size in bytes"), + metric.WithExplicitBucketBoundaries(0, 1024, 4096, 16384, 32768, 65536, 131072, 262144, 524288, 1048576), ); err != nil { return err } if otelcolReceiverPyroscopeParsedBodyUncompressedSizeBytes, err = meter.Int64Histogram( fmt.Sprint(prefix, "parsed_body_uncompressed_size_bytes"), metric.WithDescription("Pyroscope receiver uncompressed parsed body size in bytes"), + metric.WithExplicitBucketBoundaries(0, 1024, 4096, 16384, 32768, 65536, 131072, 262144, 524288, 1048576), ); err != nil { return err } if otelcolReceiverPyroscopeHttpResponseTimeMillis, err = meter.Int64Histogram( fmt.Sprint(prefix, "http_response_time_millis"), metric.WithDescription("Pyroscope receiver http response time in millis"), + metric.WithExplicitBucketBoundaries(0, 5, 10, 20, 50, 100, 200, 500, 1000, 5000), ); err != nil { return err } diff --git a/receiver/pyroscopereceiver/pyroscope_pipeline_bench_test.go b/receiver/pyroscopereceiver/pyroscope_pipeline_bench_test.go new file mode 100644 index 0000000..0bd6eaf --- /dev/null +++ b/receiver/pyroscopereceiver/pyroscope_pipeline_bench_test.go @@ -0,0 +1,45 @@ +package pyroscopereceiver + +import ( + "fmt" + "path/filepath" + "testing" +) + +type request struct { + urlParams map[string]string + jfr string +} + +// Benchmarks a running otelcol pyroscope write pipeline (collector and Clickhouse). +// Adjust collectorAddr to bench a your target if needed. +func BenchmarkPyroscopePipeline(b *testing.B) { + dist := []request{ + { + urlParams: map[string]string{ + "name": "com.example.App{dc=us-east-1,kubernetes_pod_name=app-abcd1234}", + "from": "1700332322", + "until": "1700332329", + "format": "jfr", + "sampleRate": "100", + }, + jfr: filepath.Join("testdata", "cortex-dev-01__kafka-0__cpu__0.jfr"), + }, + { + urlParams: map[string]string{ + "name": "com.example.App{dc=us-east-1,kubernetes_pod_name=app-abcd1234}", + "from": "1700332322", + "until": "1700332329", + "format": "jfr", + }, + jfr: filepath.Join("testdata", "memory_alloc_live_example.jfr"), + }, + } + collectorAddr := fmt.Sprintf("http://%s%s", defaultHttpAddr, ingestPath) + + b.ResetTimer() + for i, j := 0, 0; i < b.N; i++ { + send(collectorAddr, dist[j].urlParams, dist[j].jfr) + j = (j + 1) % len(dist) + } +} diff --git a/receiver/pyroscopereceiver/receiver_test.go b/receiver/pyroscopereceiver/receiver_test.go index fa8697b..840a731 100644 --- a/receiver/pyroscopereceiver/receiver_test.go +++ b/receiver/pyroscopereceiver/receiver_test.go @@ -46,7 +46,7 @@ func loadTestData(t *testing.T, filename string) []byte { func run(t *testing.T, tests []jfrtest, collectorAddr string, sink *consumertest.LogsSink) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.NoError(t, send(t, collectorAddr, tt.urlParams, tt.jfr), "send shouldn't have been failed") + assert.NoError(t, send(collectorAddr, tt.urlParams, tt.jfr), "send shouldn't have been failed") actual := sink.AllLogs() assert.NoError(t, plogtest.CompareLogs(tt.expected, actual[0])) sink.Reset() @@ -63,9 +63,7 @@ func startHttpServer(t *testing.T) (string, *consumertest.LogsSink) { MaxRequestBodySize: defaultMaxRequestBodySize, }, }, - Timeout: defaultTimeout, - RequestBodyUncompressedSizeBytes: defaultRequestBodyUncompressedSizeBytesExpectedValue, - ParsedBodyUncompressedSizeBytes: defaultParsedBodyUncompressedSizeBytesExpectedValue, + Timeout: defaultTimeout, } sink := new(consumertest.LogsSink) set := receivertest.NewNopCreateSettings() @@ -79,7 +77,7 @@ func startHttpServer(t *testing.T) (string, *consumertest.LogsSink) { return addr, sink } -func send(t *testing.T, addr string, urlParams map[string]string, jfr string) error { +func send(addr string, urlParams map[string]string, jfr string) error { data, err := os.ReadFile(jfr) if err != nil { return err