[Prometheus.HttpListener] Support scrape HTTP response caching#7189
Merged
martincostello merged 6 commits intoApr 28, 2026
Merged
Conversation
Add support for caching HTTP responses.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7189 +/- ##
==========================================
+ Coverage 89.25% 89.58% +0.33%
==========================================
Files 271 272 +1
Lines 13093 13445 +352
==========================================
+ Hits 11686 12045 +359
+ Misses 1407 1400 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
martincostello
commented
Apr 27, 2026
Add PR number.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds configurable scrape HTTP response caching for the Prometheus HttpListener exporter, bringing it to parity with the ASP.NET Core exporter and enabling caching by default.
Changes:
- Introduces
PrometheusHttpListenerOptions.ScrapeResponseCacheDurationMilliseconds(default 300ms; 0 disables caching). - Plumbs the configured cache duration into the
PrometheusExportercreated byAddPrometheusHttpListener. - Updates/extends unit tests and changelog/public API baselines for the new option.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerMeterProviderBuilderExtensionsTests.cs | Adds a unit test asserting configured cache duration flows into the exporter. |
| test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs | Updates theory inputs to align with new default caching behavior for HttpListener. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListenerOptions.cs | Adds new cache duration option and sets default to 300ms. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListenerMeterProviderBuilderExtensions.cs | Passes the new HttpListener option through to the exporter options. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md | Documents the new caching support in Unreleased. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/.publicApi/PublicAPI.Unshipped.txt | Adds new public API surface for the cache duration property. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
auto-merge was automatically disabled
April 27, 2026 20:09
Pull request was converted to draft
Add missing test coverage.
martincostello
commented
Apr 28, 2026
Update out-of-date comments.
Kielek
reviewed
Apr 28, 2026
Update README and CHANGELOG.
Kielek
approved these changes
Apr 28, 2026
4 tasks
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.
Changes
Add support for caching HTTP responses in
OpenTelementry.Exporter.Prometheus.HttpListener.This creates parity with the ASP.NET Core exporter instead of forcing it to be disabled.
If we'd rather keep the current behaviour by default, I can change the default back to 0.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes