diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/mapping/logarithm_mapping.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/mapping/logarithm_mapping.py index e73f3a81e23..980be890aef 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/mapping/logarithm_mapping.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/mapping/logarithm_mapping.py @@ -47,8 +47,12 @@ def _get_min_scale(self): return self._min_scale def _get_max_scale(self): - # FIXME The Go implementation uses a value of 20 here, find out the - # right value for this implementation, more information here: + # _max_scale is 20. The OpenTelemetry specification requires that + # bucket indices fit within a signed 32-bit integer. At scale 20, + # the maximum bucket index is ((MAX_NORMAL_EXPONENT + 1) << 20) - 1, + # which fits within this range. At scale 21, the maximum bucket + # index reaches the upper limit of a signed 32-bit integer, making + # it difficult to test correctness. See: # https://github.com/lightstep/otel-launcher-go/blob/c9ca8483be067a39ab306b09060446e7fda65f35/lightstep/sdk/metric/aggregator/histogram/structure/README.md#mapping-function # https://github.com/open-telemetry/opentelemetry-go/blob/0e6f9c29c10d6078e8131418e1d1d166c7195d61/sdk/metric/aggregator/exponential/mapping/logarithm/logarithm.go#L32-L45 return self._max_scale