Skip to content

feat: add support for configuring scope info metric attributes for the Prometheus exporter#5123

Open
herin049 wants to merge 6 commits intoopen-telemetry:mainfrom
herin049:feat/prometheus-scope-info
Open

feat: add support for configuring scope info metric attributes for the Prometheus exporter#5123
herin049 wants to merge 6 commits intoopen-telemetry:mainfrom
herin049:feat/prometheus-scope-info

Conversation

@herin049
Copy link
Copy Markdown
Contributor

@herin049 herin049 commented Apr 18, 2026

Description

Adds support for configuring scope attributes for the Prometheus exporter in accordance to the Prometheus spec

Fixes #5112

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?

uv run tox -e py314-test-opentelemetry-exporter-prometheus

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

@herin049 herin049 requested a review from a team as a code owner April 18, 2026 04:33
@herin049 herin049 added the Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary label Apr 18, 2026
@herin049 herin049 moved this to Ready for review in Python PR digest Apr 18, 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.

This looks like it's on the right path. A few things to note:

  1. _SCOPE_ATTR_CONFLICT_NAMES is defined but never used — we should either use it to explicitly filter conflicting scope attributes or remove it.

  2. PR description looks copy-pasted from #5122 — says "Resource metrics as Metric attributes" but this is about scope info.

  3. Merge conflict concern — this, #5122, #5118, and #5117 all modify PrometheusMetricReader and _translate_to_prometheus. This is going to conflict with them, we need to coordinate what should be done in order or we'll be bumping into each other with rebases.

  4. nit: the nesting depth in _translate_to_prometheus is getting deep — might be worth extracting the per-metric logic into a helper in a follow-up.

@MikeGoldsmith MikeGoldsmith moved this from Ready for review to Approved PRs that need fixes in Python PR digest Apr 21, 2026
@herin049
Copy link
Copy Markdown
Contributor Author

This looks like it's on the right path. A few things to note:

  1. _SCOPE_ATTR_CONFLICT_NAMES is defined but never used — we should either use it to explicitly filter conflicting scope attributes or remove it.
  2. PR description looks copy-pasted from feat: add support for Resource attributes configuration for Prometheus exporter #5122 — says "Resource metrics as Metric attributes" but this is about scope info.
  3. Merge conflict concern — this, feat: add support for Resource attributes configuration for Prometheus exporter #5122, feat: add metric name translation strategy support for the Prometheus exporter #5118, and feat(exporter/prometheus): add default_aggregation parameter to PrometheusMetricReader #5117 all modify PrometheusMetricReader and _translate_to_prometheus. This is going to conflict with them, we need to coordinate what should be done in order or we'll be bumping into each other with rebases.
  4. nit: the nesting depth in _translate_to_prometheus is getting deep — might be worth extracting the per-metric logic into a helper in a follow-up.

Sorry, got a little sloppy with this PR. I originally used _SCOPE_ATTR_CONFLICT_NAMES, but refactored the code so that it isn't needed anymore. The update order shouldn't matter much, I can address the merge conflicts as they come in. Updated the PR description, will clean up the PR.

@herin049
Copy link
Copy Markdown
Contributor Author

@MikeGoldsmith I ended up doing a pretty major refactor of the exporter logic based on your suggestion, so we will likely want to merge this PR first.

@herin049 herin049 moved this from Approved PRs that need fixes to Ready for review 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

Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary exporters

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Stabilize Prometheus Exporter: Scope Info

2 participants