Skip to content

Fix PrometheusHttpServerBuilder copy constructor dropping the default handler#8619

Draft
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/prometheus-http-server-to-builder-default-handler
Draft

Fix PrometheusHttpServerBuilder copy constructor dropping the default handler#8619
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/prometheus-http-server-to-builder-default-handler

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8618

Description

  • The package-private PrometheusHttpServerBuilder copy constructor copied 8 of the builder's 9 fields, omitting defaultHandler and silently losing an HttpHandler set via setDefaultHandler().
  • build() stores a defensive copy on the server and toBuilder() copies that again, so toBuilder() users lose the handler despite the documented "same configuration as this instance" contract. The first build() is unaffected — it passes defaultHandler from the field directly.
  • Added the missing assignment in field-declaration order, matching the adjacent authenticator line: an identical @Nullable, setter-only field passed to HTTPServer.builder(). The field arrived in Make /metrics the only Prometheus metrics endpoint #6476 without a copy-constructor line; memoryMode had the same omission, fixed later in Enable reusuable_data memory mode by default #6799.

Testing done

  • Extended PrometheusHttpServerTest#toBuilder: the new assertion fails with expected: <handler> but was: null before the fix, passes after.
  • ./gradlew :exporters:prometheus:check — 191 tests plus 1 testJpms test pass.
  • CHANGELOG.md ## Unreleased entry added. No apidiff: signatures unchanged, alpha module untracked in docs/apidiffs/.
  • Not run: *IT and GraalVM native-image tests (outside check).

@thswlsqls
thswlsqls force-pushed the fix/prometheus-http-server-to-builder-default-handler branch from 4895b3c to 8d2370a Compare July 17, 2026 00:49
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.60%. Comparing base (63ebd94) to head (8d2370a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8619      +/-   ##
============================================
- Coverage     91.63%   91.60%   -0.03%     
- Complexity    10326    10343      +17     
============================================
  Files          1013     1013              
  Lines         27295    27353      +58     
  Branches       3205     3215      +10     
============================================
+ Hits          25011    25058      +47     
- Misses         1558     1567       +9     
- Partials        726      728       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

PrometheusHttpServer.toBuilder() drops the configured default handler

1 participant