Skip to content

opentelemetry-exporter-prometheus: fix wrong labels when metrics share a name - #5694

Draft
jbyers44 wants to merge 1 commit into
open-telemetry:mainfrom
jbyers44:prometheus-family-label-names
Draft

jbyers44 wants to merge 1 commit into
open-telemetry:mainfrom
jbyers44:prometheus-family-label-names

Conversation

@jbyers44

Copy link
Copy Markdown

Description

Builds each metric family with the union of the label keys of all its data points.

  • prometheus_client sets the label names of a family when it creates the family. add_metric then matches values to those names by position. collect() now creates each family only after it has all of that family's points.
  • A missing label key gets "", as it already does for points within one metric. Each metric name keeps one HELP and one TYPE line, as in Fix duplicate HELP/TYPE declarations in Prometheus exporter #4869.
  • collect() now yields target_info directly, because the dict now holds _FamilyBuilder objects, not finished families.
  • If more than one batch is queued when a scrape starts, the output has duplicate HELP, TYPE, and series lines, as on main.

Fixes #5685

Type of change

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

How Has This Been Tested?

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

…e a name

Builds each metric family with the union of the label keys of all its
data points. Previously, the exporter put the label values of later
metrics in a family under the label keys of the first one, by position.

Assisted-by: Claude Opus 5.5
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-09-25 17:13 UTC

Move out of draft to request review.

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.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

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

None yet

Development

Successfully merging this pull request may close these issues.

Prometheus exporter puts label values under the wrong label names when two instruments share a name

1 participant