Skip to content

Conversation

@Antrakos
Copy link

@Antrakos Antrakos commented Jan 6, 2026

Description

The Prometheus exporter was generating duplicate HELP and TYPE declarations for metrics with varying label sets, violating the Prometheus format specification and causing rejection by Prometheus Pushgateway with the error: "second HELP line for metric name."

Changes:

  • Modified metric family ID to exclude label keys, using only metric name, description, and unit
  • Implemented two-pass processing: first pass collects all unique label keys across data points, second pass builds label values with empty strings for missing labels
  • Ensured single metric family per metric type with consolidated label keys
  • Updated test expectations to verify single HELP/TYPE declaration with proper empty string handling for missing labels

This aligns with the Go implementation approach and ensures compatibility with Prometheus Pushgateway and other strict validators.

Fixes #4868

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests
  • My application.
    It's important to set OTEL_SEMCONV_STABILITY_OPT_IN=http and make both successful and failed requests, then optional error_type label would previously cause duplicate metrics and now be set to empty string if not present.

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

Fixes open-telemetry#4868

The Prometheus exporter was generating duplicate HELP and TYPE
declarations for metrics with varying label sets, violating the
Prometheus format specification and causing rejection by Prometheus
Pushgateway with the error: "second HELP line for metric name."

Changes:
- Modified metric family ID to exclude label keys, using only metric
  name, description, and unit
- Implemented two-pass processing: first pass collects all unique
  label keys across data points, second pass builds label values with
  empty strings for missing labels
- Ensured single metric family per metric type with consolidated
  label keys
- Updated test expectations to verify single HELP/TYPE declaration
  with proper empty string handling for missing labels

This aligns with the Go implementation approach and ensures
compatibility with Prometheus Pushgateway and other strict validators.
@Antrakos Antrakos requested a review from a team as a code owner January 6, 2026 18:49
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 6, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Antrakos / name: Taras Zubrei (cc5b23f)

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 creates duplicate HELP/TYPE declarations for metrics with different label sets

1 participant