Skip to content

Reject exponential histogram aggregation views for async instruments - #5461

Open
Eason09053360 wants to merge 9 commits into
open-telemetry:mainfrom
Eason09053360:fix-async-exponential-histogram-incompatibility
Open

Reject exponential histogram aggregation views for async instruments#5461
Eason09053360 wants to merge 9 commits into
open-telemetry:mainfrom
Eason09053360:fix-async-exponential-histogram-incompatibility

Conversation

@Eason09053360

@Eason09053360 Eason09053360 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description

A View configuring ExponentialBucketHistogramAggregation on an
asynchronous instrument (e.g. ObservableCounter) is currently accepted
without any warning, but silently produces no data points forever:
asynchronous instruments report with CUMULATIVE instrument temporality, and
_ExponentialBucketHistogramAggregation.collect() only implements the DELTA
instrument temporality path, so every collection falls through and returnsNone.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • opentelemetry-sdk/tests/metrics/
  • test_metric_reader_storage.py

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@Eason09053360
Eason09053360 requested a review from a team as a code owner July 26, 2026 14:25
@Eason09053360
Eason09053360 marked this pull request as draft July 26, 2026 14:26
@Eason09053360
Eason09053360 force-pushed the fix-async-exponential-histogram-incompatibility branch from 58a8dde to 4cd9352 Compare July 26, 2026 14:45
@Eason09053360
Eason09053360 marked this pull request as ready for review July 26, 2026 14:50
@Eason09053360
Eason09053360 force-pushed the fix-async-exponential-histogram-incompatibility branch from 4cd9352 to 64ab962 Compare August 1, 2026 16:38
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 14, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-08-30 10:20 UTC

Investigate required status check failures.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

Comment thread .changelog/5461.fixed Outdated

Copilot AI 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.

Pull request overview

This pull request addresses a metrics SDK edge case where a View configured with ExponentialBucketHistogramAggregation on an asynchronous instrument (e.g., ObservableCounter) would previously be accepted but then produce no data points due to temporality/aggregation incompatibility. The change aligns behavior with existing handling for explicit histograms by warning and not applying the incompatible view, falling back to the default view instead.

Changes:

  • Reject (warn + do not apply) View/instrument matches where an asynchronous instrument is paired with ExponentialBucketHistogramAggregation.
  • Add a unit test to verify the exponential-histogram + async-instrument view is rejected and the default view is used.
  • Add a changelog entry documenting the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/metric_reader_storage.py Extends async-instrument compatibility checks to also reject exponential histogram aggregations.
opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py Adds coverage for rejecting exponential histogram aggregation views on async instruments (warning emitted; default view applied).
.changelog/5461.fixed Documents the behavior change/fix in the changelog system.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Eason09053360

Copy link
Copy Markdown
Contributor Author

The CI failures here are unrelated to this change:

opentelemetry-sdk pypy-3.10 Windows: test_shutdown_allows_1_export_to_finish[BatchSpanProcessor-telemetry1] fails on assert processor._batch_processor._worker_thread.is_alive() is True right after shutdown(timeout_millis=3000) returns — a timing assumption that doesn't hold on slow pypy/Windows runners.

This PR only touches metrics view compatibility. Could you rerun the failed jobs when you get a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants