Skip to content

Add registry keyword argument to PrometheusMetricReader#5055

Open
Manvi2402 wants to merge 2 commits intoopen-telemetry:mainfrom
Manvi2402:fix/prometheus-registry-kwarg
Open

Add registry keyword argument to PrometheusMetricReader#5055
Manvi2402 wants to merge 2 commits intoopen-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
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.

Don't hard-code the global REGISTRY in PrometheusMetricReader

1 participant