Skip to content

Fix missing f-prefix in exponential histogram max_size error messages#5434

Open
Eason09053360 wants to merge 3 commits into
open-telemetry:mainfrom
Eason09053360:fix-fstring-prefix-exponential-histogram
Open

Fix missing f-prefix in exponential histogram max_size error messages#5434
Eason09053360 wants to merge 3 commits into
open-telemetry:mainfrom
Eason09053360:fix-fstring-prefix-exponential-histogram

Conversation

@Eason09053360

@Eason09053360 Eason09053360 commented Jul 18, 2026

Copy link
Copy Markdown

Description

The two ValueError messages in _ExponentialBucketHistogramAggregation are built by concatenating an f-string with a plain string literal, and the continuation lines were missing the f prefix. As a result, users saw the literal placeholder text instead of the actual limits:

Buckets max size 1 is smaller than minimum max size {self._min_max_size}

This PR adds the missing f prefix to both continuation strings, so the messages now render the actual values:

Buckets max size 1 is smaller than minimum max size 2
Buckets max size 20000 is larger than maximum max size 16384

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Manually triggered both error paths and verified the rendered messages:

from opentelemetry.sdk.metrics._internal.aggregation import _ExponentialBucketHistogramAggregation
from unittest.mock import Mock

for size in (1, 20000):
    try:
        _ExponentialBucketHistogramAggregation(Mock(), Mock(), 0, 0, max_size=size)
    except ValueError as e:
        print(e)

Existing unit tests for _ExponentialBucketHistogramAggregation still pass.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated

The continuation strings of the two ValueError messages in
_ExponentialBucketHistogramAggregation lacked the f prefix, so the
literal text {self._min_max_size} / {self._max_max_size} was printed
instead of the actual limits (2 / 16384).
@Eason09053360
Eason09053360 requested a review from a team as a code owner July 18, 2026 18:02

@herin049 herin049 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changelog fragement.

@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Jul 18, 2026
@Eason09053360

Copy link
Copy Markdown
Author

Please add a changelog fragement.

applied thanks :)

@emdneto emdneto moved this from Approved PRs to Ready for merge in Python PR digest Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for merge

Development

Successfully merging this pull request may close these issues.

4 participants