Skip to content

opentelemetry-exporter-prometheus: omit empty target_info metric - #5939

Open
dashpole wants to merge 1 commit into
open-telemetry:mainfrom
dashpole:fix-empty-target-info-3455
Open

dashpole wants to merge 1 commit into
open-telemetry:mainfrom
dashpole:fix-empty-target-info-3455

Conversation

@dashpole

Copy link
Copy Markdown
Contributor

Description

Update _CustomCollector.collect in opentelemetry-exporter-prometheus to only create and yield the target_info metric when the merged resource attributes are non-empty, matching the OpenTelemetry Prometheus compatibility specification.

(Note: the otel_scope_info part of #3455 was superseded by open-telemetry/opentelemetry-specification#5052 and implemented via otel_scope_* labels in #5123.)

Fixes #3455

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • I am a human and not a bot
  • I have run tox -e precommit
  • I have run tox -e typecheck
  • I have run the relevant tests and linting tox environments
  • This requires the following PR in contrib:

@dashpole
dashpole force-pushed the fix-empty-target-info-3455 branch from d1ff693 to 4f890eb Compare November 14, 2026 21:44
@dashpole
dashpole requested a balanced review from Copilot November 14, 2026 21:45
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-15 07:27 UTC

Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1
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.

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@dashpole
dashpole marked this pull request as ready for review November 14, 2026 23:12
@dashpole
dashpole requested a review from a team as a code owner November 14, 2026 23:12
@herin049
herin049 requested a balanced review from Copilot November 15, 2026 07:25

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.

🟢 Approval recommended

No active review issues remain for the change to omit target_info when resource attributes are empty.

No open issues 🎉

Review effort: Balanced

self.assertNotIn("os", prometheus_metric.samples[0].labels)
self.assertNotIn("version", prometheus_metric.samples[0].labels)

def test_target_info_omitted_when_resource_empty(self):

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 also add one or two scenarios that utilize the self.verify_text_format helper?

This branch has not been deployed

No deployments
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.

Prometheus exporter: omit empty otel_scope_info and otel_target_info metrics

3 participants