Skip to content

Commit c3da0c9

Browse files
committed
sdk/metric: document unit-sensitivity of DefaultAggregationSelector
The default ExplicitBucketHistogram boundaries returned by DefaultAggregationSelector are tuned for millisecond-scale measurements and are not rescaled when an instrument is created with metric.WithUnit("s") or any other unit. Add a godoc note so users reading the selector can see this and point them at the knobs for overriding the boundaries. Fixes #5891 Signed-off-by: Ali <alliasgher123@gmail.com>
1 parent 2fe7910 commit c3da0c9

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3030
- `ErrorType` in `go.opentelemetry.io/otel/semconv` now unwraps errors created with `fmt.Errorf` when deriving the `error.type` attribute. (#8133)
3131
- `go.opentelemetry.io/otel/sdk/log` now unwraps error chains created with `fmt.Errorf` when deriving the `error.type` attribute from errors on log records. (#8133)
3232
- `Set.MarshalLog` method in `go.opentelemetry.io/otel/attribute` now uses `Value.String` formatting following the [OpenTelemetry AnyValue representation for non-OTLP protocols](https://opentelemetry.io/docs/specs/otel/common/#anyvalue). (#8169)
33+
- Document that the default `ExplicitBucketHistogram` boundaries returned by `DefaultAggregationSelector` in `go.opentelemetry.io/otel/sdk/metric` are tuned for milliseconds and are not rescaled when an instrument is created with a different unit. (#XXXX)
3334

3435
### Deprecated
3536

sdk/metric/reader.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ type AggregationSelector func(InstrumentKind) Aggregation
183183
// mapping: Counter ⇨ Sum, Observable Counter ⇨ Sum, UpDownCounter ⇨ Sum,
184184
// Observable UpDownCounter ⇨ Sum, Observable Gauge ⇨ LastValue,
185185
// Histogram ⇨ ExplicitBucketHistogram.
186+
//
187+
// The default ExplicitBucketHistogram boundaries are tuned for measurements
188+
// expressed in milliseconds and are not rescaled when an instrument is
189+
// created with a different unit (e.g. via
190+
// [go.opentelemetry.io/otel/metric.WithUnit]). To use different boundaries,
191+
// provide a custom [AggregationSelector] to your [Reader] or exporter, or
192+
// supply explicit per-instrument boundaries via
193+
// [go.opentelemetry.io/otel/metric.WithExplicitBucketBoundaries].
186194
func DefaultAggregationSelector(ik InstrumentKind) Aggregation {
187195
switch ik {
188196
case InstrumentKindCounter,

0 commit comments

Comments
 (0)