Skip to content

Add registry keyword argument to PrometheusMetricReader#5055

Merged
aabmass merged 13 commits into
open-telemetry:mainfrom
Manvi2402:fix/prometheus-registry-kwarg
May 8, 2026
Merged

Add registry keyword argument to PrometheusMetricReader#5055
aabmass merged 13 commits into
open-telemetry:mainfrom
Manvi2402:fix/prometheus-registry-kwarg

Conversation

@Manvi2402
Copy link
Copy Markdown
Contributor

Description

Added a registry keyword argument to PrometheusMetricReader.init(), defaulting to the global REGISTRY. This allows users to pass a custom CollectorRegistry instance, which is useful for testing scenarios that require a fresh registry per test.
Note: The second part of the issue (set_meter_provider repeated calls) is not included in this PR.

Fixes #4713

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 test_custom_registry test in test_prometheus_exporter.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

@Manvi2402 Manvi2402 requested a review from a team as a code owner April 7, 2026 16:03
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 - I've left some simple clean up to do before we accept.

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

Thanks for the review @MikeGoldsmith . I've made the requested cleanup changes. Please let me know if anything else is needed.

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. Please can you resolve the changelog conflict, there was a release recently so just needs a little clean up.

@github-project-automation github-project-automation Bot moved this from Reviewed PRs that need fixes to Approved PRs in Python PR digest Apr 13, 2026
@Manvi2402
Copy link
Copy Markdown
Contributor Author

@MikeGoldsmith Done, resolved the changelog conflict .

@aabmass aabmass enabled auto-merge (squash) May 8, 2026 21:19
@aabmass aabmass merged commit 4d27369 into open-telemetry:main May 8, 2026
955 of 957 checks passed
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Python PR digest May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Don't hard-code the global REGISTRY in PrometheusMetricReader

3 participants