Skip to content

[DNM/DNR] Prometheus compatibility fixes#7243

Draft
martincostello wants to merge 88 commits into
open-telemetry:mainfrom
martincostello:prometheus-compatibility-fixes
Draft

[DNM/DNR] Prometheus compatibility fixes#7243
martincostello wants to merge 88 commits into
open-telemetry:mainfrom
martincostello:prometheus-compatibility-fixes

Conversation

@martincostello
Copy link
Copy Markdown
Member

@martincostello martincostello commented May 3, 2026

Changes

This PR combines all of the changes from the PRs below. It is not intended to be merged, it's just to help me track the overall end-goal of those PRs once everything is fixed together.

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)

- Add support for configuring OpenTelemetry.Exporter.Prometheus.HttpListener with the `OTEL_EXPORTER_PROMETHEUS_HOST` and `OTEL_EXPORTER_PROMETHEUS_PORT` environment variables.
- Remove field for UriPrefixes and use auto-property.
- Remove `UriPrefixes` from the README.

Fixes open-telemetry#4158.
Fixes open-telemetry#7154.
Add coverage for invalid environment variables.
Remove duplicated constructor declaration.
- Add missing SHOULD requirement to specify the `escaping` value for 1.0.0 protocols.
- Update `PrometheusSerializer` to be compliant with `escaping=underscores` when using OpenMetrics.
Fix missing prefixing for metrics that start with a digit.
- Use canonical representations for numbers for "le" label values of histograms and "quantile" label values of summary metrics for OpenMetrics.
- Resolve TODO by moving check outside loop.

See https://prometheus.io/docs/specs/om/open_metrics_spec/#considerations-canonical-numbers.
Remove branches that could not be reached.
- Check destination size.
- Update CHANGELOGs.
Fix incorrect serialized value for `PrometheusType.Untyped` when using OpenMetrics.
Omit histogram `_sum` and `_count` in OpenMetrics when negative bucket thresholds are present.
Export `{name}_created` series for counters and histograms when start time is available when using OpenMetrics.
Add missing `TYPE` metadata.
- Remove non-spec `TYPE` for `_counter`.
- Fix-up timestamp precision.
Fix-up duplicated definitions.
Add missing suffix.
- Emit OpenMetrics scope metadata as a single `otel_scope` metric family with `otel_scope_info` samples instead of repeating metadata for every scope.
- Include instrumentation scope metadata on samples using `otel_scope_*` labels, including scope version, schema URL, and prefixed scope attributes.
- Drop conflicting scope attributes named `name`, `version`, and `schema_url` to avoid collisions with generated scope labels.
Remove Go theme for .NET.
Address Copilot review feedback.
Add more test coverage for patch.
Add Prometheus text fallback `target_info` output as a gauge so resource metadata is still exposed as Info-typed metrics are unavailable for PrometheusText exposition format.
Merge colliding sanitized label keys by concatenating values in lexicographic order of the original keys.
Set bind-mount file permissions on Linux.
Extend the ASP.NET Core integration tests to include interop between ASP.NET Core and Prometheus itself to scrape metrics.
Observe client requests to abort scrape request processing, including via `X-Prometheus-Scrape-Timeout-Seconds`, and respond with an HTTP 408.
- Log exceptions calling Prometheus.
- Use top-level cancellation instead of nested.
- Delete temporary configuration files.
Use `ImmutableHashSet<T>` where available.
- Constrain accepted `X-Prometheus-Scrape-Timeout-Seconds` values.
- Check cancellation token source.
- Do not try to set the status if response has started.
…out-Seconds' into prometheus-compatibility-fixes
Fix exception being thrown if `OTEL_SDK_DISABLED=true`.

See open-telemetry#7272.
- Disable SDK with in-memory configuration instead of environment variables.
- Remove accidentally added environment variable to other integration test.
Avoid creating an `PrometheusExporter` and `PrometheusCollectionManager` with 170KB memory overhead when the SDK is disabled.
Extend the ASP.NET Core integration tests to include interop between ASP.NET Core and Prometheus itself to scrape metrics.
- Log exceptions calling Prometheus.
- Use top-level cancellation instead of nested.
- Delete temporary configuration files.
Add support for GZip compression.

Resolves open-telemetry#7213.
@martincostello martincostello added the keep-open Prevents issues and pull requests being closed as stale label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keep-open Prevents issues and pull requests being closed as stale 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant