From 2f55131798058d53909acf43fd67b5293d704932 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Thu, 5 Mar 2026 20:57:54 +0000 Subject: [PATCH] use correct bucket boundaries for otelgrpc client and server histograms --- CHANGELOG.md | 1 + .../grpc/otelgrpc/stats_handler.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d91fb793463..492476d1282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Ignore informational response status codes (`100-199`) except `101 Switching Protocols` when storing the HTTP status code in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` and `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`. (#6913) - Make `Body` handling in `Transport` consistent with stdlib in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#8618) +- Fix bucket boundaries for `rpc.server.call.duration` and `rpc.client.call.duration` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8642) ### Removed diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go b/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go index 3a681debd55..be9282f29f6 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go @@ -59,7 +59,13 @@ func NewServerHandler(opts ...Option) stats.Handler { ) var err error - h.duration, err = rpcconv.NewServerCallDuration(meter) + h.duration, err = rpcconv.NewServerCallDuration( + meter, + metric.WithExplicitBucketBoundaries( + 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, + 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10, + ), + ) if err != nil { otel.Handle(err) } @@ -162,7 +168,13 @@ func NewClientHandler(opts ...Option) stats.Handler { ) var err error - h.duration, err = rpcconv.NewClientCallDuration(meter) + h.duration, err = rpcconv.NewClientCallDuration( + meter, + metric.WithExplicitBucketBoundaries( + 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, + 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10, + ), + ) if err != nil { otel.Handle(err) }