Skip to content

feat(exporter/prometheus): add default_aggregation parameter to PrometheusMetricReader#5117

Open
Manvi2402 wants to merge 6 commits intoopen-telemetry:mainfrom
Manvi2402:fix/prometheus-default-aggregation
Open

feat(exporter/prometheus): add default_aggregation parameter to PrometheusMetricReader#5117
Manvi2402 wants to merge 6 commits intoopen-telemetry:mainfrom
Manvi2402:fix/prometheus-default-aggregation

Conversation

@Manvi2402
Copy link
Copy Markdown
Contributor

Description

Add default_aggregation parameter to PrometheusMetricReader to allow configuring default aggregation per instrument kind, aligning with the Prometheus Exporter spec.

Fixes #5109

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?

  • Test A: Added unit test test_default_aggregation in test_prometheus_exporter.py
    that verifies custom aggregation is correctly passed to the MetricReader.

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

Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

This looks good, thanks @Manvi2402. I've left some things to tweak.

I think it's gonna conflict with @herin049's PR (#5118). Whoever's PR merges later will likely have a conflict to resolve.

Comment thread exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py Outdated
Comment thread CHANGELOG.md Outdated
@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Apr 17, 2026
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Looks good - thanks @Manvi2402 👍🏻

histogram = meter.create_histogram("test_histogram")
histogram.record(5)
result = list(reader._collector.collect())
self.assertTrue(len(result) > 0)
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.

Can we do some additional verification here to actually verify that the boundaries specified above are respected?

@github-project-automation github-project-automation Bot moved this from Approved PRs to Reviewed PRs that need fixes in Python PR digest Apr 22, 2026
@herin049 herin049 moved this from Reviewed PRs that need fixes to Approved PRs that need fixes in Python PR digest Apr 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: Approved PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Stabilize Prometheus Exporter: Default Aggregation

3 participants