Skip to content

[Exporter.Prometheus] Fix spec-compliance issues#7454

Merged
martincostello merged 7 commits into
open-telemetry:mainfrom
martincostello:fix-prometheus-issues
Jun 24, 2026
Merged

[Exporter.Prometheus] Fix spec-compliance issues#7454
martincostello merged 7 commits into
open-telemetry:mainfrom
martincostello:fix-prometheus-issues

Conversation

@martincostello

@martincostello martincostello commented Jun 23, 2026

Copy link
Copy Markdown
Member

Changes

  • Fix double unit suffixes in metric names when using OpenMetrics.
  • Fix incorrect handling of leading digits in metric names for OpenMetrics.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

- Fix double unit suffixes in metric names when using OpenMetrics.
- Fix incorrect handling of leading digits in metric names for OpenMetrics.
- Fix incorrect `Content-Type` for PrometheusText.
@martincostello martincostello added the spec-compliance Issues related to compliance with the OpenTelemetry Specification label Jun 23, 2026
Comment thread src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md Outdated
@github-actions github-actions Bot added pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package labels Jun 23, 2026
Comment thread src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Outdated
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.85%. Comparing base (06e5c61) to head (0651c66).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7454      +/-   ##
==========================================
- Coverage   89.94%   89.85%   -0.10%     
==========================================
  Files         277      277              
  Lines       14637    14642       +5     
==========================================
- Hits        13165    13156       -9     
- Misses       1472     1486      +14     
Flag Coverage Δ
unittests-Project-Experimental 89.75% <100.00%> (-0.17%) ⬇️
unittests-Project-Stable 89.75% <100.00%> (-0.14%) ⬇️
unittests-UnstableCoreLibraries-Experimental 48.86% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...s.HttpListener/Internal/Shared/PrometheusMetric.cs 99.46% <100.00%> (+0.01%) ⬆️

... and 4 files with indirect coverage changes

@martincostello
martincostello marked this pull request as ready for review June 23, 2026 17:17
@martincostello
martincostello requested a review from a team as a code owner June 23, 2026 17:18
Copilot AI review requested due to automatic review settings June 23, 2026 17:18
@martincostello
martincostello enabled auto-merge June 23, 2026 17:18

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.

Pull request overview

This PR targets spec-compliance fixes in the Prometheus exporters (HttpListener + ASP.NET Core), primarily around OpenMetrics metric naming and scrape response Content-Type generation.

Changes:

  • Adjust OpenMetrics metric name sanitization (leading digits handling) and unit-suffix behavior for counters.
  • Update Content-Type generation logic and expand/adjust protocol-related test coverage.
  • Add changelog entries for both Prometheus exporter packages.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusProtocolTests.cs Adds GetContentType/ToString protocol tests (currently asserts PrometheusText omits charset).
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusMetricTests.cs Updates OpenMetrics naming tests (leading digits + unit/_total interactions).
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs Updates integration expectations for scrape Content-Type.
test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusIntegrationTests.cs Updates ASP.NET Core scrape test Content-Type expectation.
test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusExporterMiddlewareTests.cs Updates middleware integration expectations for scrape Content-Type.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusProtocol.cs Changes Content-Type composition (charset now conditional on OpenMetrics).
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusMetric.cs Fixes OpenMetrics unit suffix duplication for counters; adjusts leading-digit escaping behavior.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Records the spec-compliance fixes.
src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md Records the spec-compliance fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Revert the changes to the `Content-Type` header's `charset`.
Fix issue with counter suffixes.
Rename tests to be less specific.
@Kielek
Kielek disabled auto-merge June 24, 2026 05:47

@Kielek Kielek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed some direct feedback, please double check and merge if you are fine.

@martincostello
martincostello added this pull request to the merge queue Jun 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 24, 2026
@martincostello
martincostello added this pull request to the merge queue Jun 24, 2026
Merged via the queue into open-telemetry:main with commit f544847 Jun 24, 2026
76 checks passed
@martincostello
martincostello deleted the fix-prometheus-issues branch June 24, 2026 07:34
This was referenced Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package spec-compliance Issues related to compliance with the OpenTelemetry Specification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants