You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
db.client.operation.duration histogram uses wrong default bucket boundaries (all observations fall into first bucket) #631
The db.client.operation.duration histogram is created without the WithExplicitBucketBoundaries advisory option. In instruments.go, newInstruments calls:
and the generated dbconv.NewClientOperationDuration helper (from go.opentelemetry.io/otel/semconv/v1.40.0/dbconv) only sets the description and unit — it does not set bucket boundaries either. As a result, the histogram falls back to the OTel SDK's generic default boundaries:
These defaults were designed for millisecond-scale values, but this metric's unit is seconds. Typical MySQL/PostgreSQL operations complete in 1–50 ms (0.001–0.05 s), so essentially 100% of observations land in the very first bucket (le=5.0, i.e. ≤ 5 seconds). All cumulative buckets above it are identical, which makes the histogram useless: histogram_quantile returns the same constant value for p50, p95, and p99.
This metric SHOULD be specified with ExplicitBucketBoundaries of [ 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10 ].
This is a known OTel-wide issue: open-telemetry/opentelemetry-specification#3525 ("Default histogram bucket boundaries don't work for seconds durations"). The OTel TC decided not to change the SDK defaults and instead expects instrumentation authors to pass the advisory bucket boundaries. The same bug was reported and fixed in the npgsql .NET driver: npgsql/npgsql#6167.
Symptom
In Prometheus/Grafana, histogram_quantile(0.5, ...), histogram_quantile(0.95, ...), and histogram_quantile(0.99, ...) over db_client_operation_duration_seconds_bucket all return the same constant value (linear interpolation inside the single populated bucket), regardless of actual query latency.
Fix
Pass the spec-recommended boundaries when creating the instrument:
metric.WithExplicitBucketBoundaries is already available in go.opentelemetry.io/otel/metric — no new dependencies needed. Users who need different boundaries can still override them with metric Views.
Activity