Repository navigation
fix(prometheus-exporter): align label sets across instruments sharing a metric family - #5918
Open
anjalimishra-0007 wants to merge 2 commits into
Conversation
… a metric family Assisted-by: Google Antigravity Signed-off-by: Anjali Mishra <246823347+anjalimishra-0007@users.noreply.github.com>
Pull request dashboard statusWaiting on reviewers · refreshed 2026-11-11 10:52 UTC Review the latest changes. Status above doesn't look right?
|
Assisted-by: Google Antigravity Signed-off-by: Anjali Mishra <246823347+anjalimishra-0007@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5685
When two instruments (for example across different instrumentation scopes) share the same Prometheus metric family ID (
metric_name,description,unit, and family type),_CustomCollectorpreviously created the*MetricFamilyusing only the first metric's sorted label keys and then appended subsequent metrics' points positionally. If another instrument carried additional or different attribute keys, values were shifted into the wrong label names or silently truncated.This change introduces
_PendingMetricFamilyinsideexporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/__init__.pyso_CustomCollector.collectgathers data points across all metrics and queuedMetricsDatabatches sharing a family ID first, computes the unified sorted label-key union, and backfills missing labels with""before instantiating and populating each Prometheus family once.Type of change
Checklist:
tox -e precommittox -e typecheckTesting & checks run locally in an isolated Python 3.13 virtualenv (
exporter/opentelemetry-exporter-prometheus):pytest exporter/opentelemetry-exporter-prometheus/tests -v: 44 passed (including new tests for histograms, counters, gauges, and queuedMetricsDatabatches sharing metric families across scopes/label sets)ruff check exporter/opentelemetry-exporter-prometheus: all checks passedruff format --check exporter/opentelemetry-exporter-prometheus: all 7 files formattedpylint --rcfile ../.pylintrc opentelemetry-exporter-prometheus: 10.00/10