Skip to content

[Exporter.Prometheus] Remove DisableTimestamp#7176

Merged
martincostello merged 4 commits into
open-telemetry:mainfrom
martincostello:gh-7150
Apr 27, 2026
Merged

[Exporter.Prometheus] Remove DisableTimestamp#7176
martincostello merged 4 commits into
open-telemetry:mainfrom
martincostello:gh-7150

Conversation

@martincostello

@martincostello martincostello commented Apr 26, 2026

Copy link
Copy Markdown
Member

Fixes #7150

Changes

Removes the DisableTimestamp option from both OpenTelemetry.Exporter.Prometheus.AspNetCore and OpenTelemetry.Exporter.Prometheus.HttpListener.

As the Prometheus spec is MUST NOT and OpenMetrics is SHOULD NOT, I thought the cleanest option was complete removal, especially as these packages aren't stable yet anyway.

Alternative approaches could be:

  1. Swap the default value to true.
  2. Deprecate via [Obsolete] before removing.
  3. Keep the property but document and implement it to only apply to OpenMetrics format.
  4. 1, 2 & 3.

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)

Removes the `DisableTimestamp` option from both OpenTelemetry.Exporter.Prometheus.AspNetCore and OpenTelemetry.Exporter.Prometheus.HttpListener.

Contributes to open-telemetry#7150.
@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 perf Performance related labels Apr 26, 2026
Comment thread src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Outdated
Note the breaking change.
@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.00%. Comparing base (9b45df9) to head (e441126).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7176      +/-   ##
==========================================
- Coverage   89.08%   89.00%   -0.08%     
==========================================
  Files         271      271              
  Lines       13073    13043      -30     
==========================================
- Hits        11646    11609      -37     
- Misses       1427     1434       +7     
Flag Coverage Δ
unittests-Project-Experimental 88.90% <100.00%> (-0.14%) ⬇️
unittests-Project-Stable 88.86% <100.00%> (-0.13%) ⬇️
unittests-UnstableCoreLibraries-Experimental 40.59% <100.00%> (-0.22%) ⬇️

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

Files with missing lines Coverage Δ
...ometheus.AspNetCore/PrometheusAspNetCoreOptions.cs 50.00% <ø> (-12.50%) ⬇️
...tpListener/Internal/PrometheusCollectionManager.cs 85.51% <100.00%> (-0.10%) ⬇️
...etheus.HttpListener/Internal/PrometheusExporter.cs 95.45% <ø> (-0.38%) ⬇️
...HttpListener/Internal/PrometheusExporterOptions.cs 100.00% <100.00%> (ø)
...heus.HttpListener/Internal/PrometheusSerializer.cs 87.05% <ø> (-0.72%) ⬇️
...s.HttpListener/Internal/PrometheusSerializerExt.cs 100.00% <100.00%> (ø)
...theusHttpListenerMeterProviderBuilderExtensions.cs 81.25% <ø> (-0.57%) ⬇️
...heus.HttpListener/PrometheusHttpListenerOptions.cs 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

@martincostello martincostello marked this pull request as ready for review April 26, 2026 14:46
@martincostello martincostello requested a review from a team as a code owner April 26, 2026 14:46
Copilot AI review requested due to automatic review settings April 26, 2026 14:46

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

Removes the DisableTimestamp configuration surface from the Prometheus exporters and updates the shared serializer implementation to never emit explicit sample timestamps, aligning behavior with Prometheus/OpenMetrics guidance and the linked issue.

Changes:

  • Removed DisableTimestamp from PrometheusAspNetCoreOptions and PrometheusHttpListenerOptions (plus associated internal plumbing).
  • Updated the Prometheus serializer to stop writing timestamps and removed the now-unused timestamp writer helper.
  • Updated unit/integration tests and benchmarks to reflect the new timestamp-less output.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusSerializerTests.cs Updates serializer output assertions to no longer expect timestamps; removes disableTimestamp parameterization.
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs Updates integration tests to stop configuring/expecting timestamps.
test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusExporterMiddlewareTests.cs Updates middleware integration tests to stop configuring/expecting timestamps (and removes timestamp parsing logic).
test/Benchmarks/Exporter/PrometheusSerializerBenchmarks.cs Updates benchmark call site for the new serializer signature without disableTimestamp.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListenerOptions.cs Removes public DisableTimestamp option from HttpListener options.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListenerMeterProviderBuilderExtensions.cs Stops forwarding DisableTimestamp into exporter options.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializerExt.cs Removes timestamp emission during metric point serialization and updates method signature.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializer.cs Removes WriteTimestamp helper since timestamps are no longer written.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusExporterOptions.cs Removes DisableTimestamp and adjusts options initialization.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusExporter.cs Removes internal DisableTimestamp state.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs Updates serializer invocation to new signature (no timestamp flag).
src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Notes breaking change for PrometheusHttpListenerOptions removal.
src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/PublicAPI.Unshipped.txt Removes unshipped API entries for DisableTimestamp on HttpListener options.
src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusAspNetCoreOptions.cs Removes public DisableTimestamp option from AspNetCore options.
src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md Notes breaking change for PrometheusAspNetCoreOptions removal.
src/OpenTelemetry.Exporter.Prometheus.AspNetCore/.publicApi/PublicAPI.Unshipped.txt Removes unshipped API entries for DisableTimestamp on AspNetCore options.

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

Comment thread src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md Outdated
Update text for PR link.

@cijothomas cijothomas 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.

Agree with this. (left non-blocking comments about unrelated changed)

@martincostello martincostello added this pull request to the merge queue Apr 27, 2026
Merged via the queue into open-telemetry:main with commit 191daf0 Apr 27, 2026
124 of 126 checks passed
@martincostello martincostello deleted the gh-7150 branch April 27, 2026 06:25
This was referenced Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Performance related 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.

[Exporter.Prometheus.AspNetCore] Remove explicit timestamps on Metric points

4 participants