Describe the bug
PrometheusHttpServer.toBuilder() returns a builder that has lost the HttpHandler set via PrometheusHttpServerBuilder.setDefaultHandler(). A server rebuilt from that builder no longer serves metrics on /.
Steps to reproduce
HttpHandler handler = exchange -> { /* serve metrics on "/" */ };
PrometheusHttpServer server = PrometheusHttpServer.builder().setDefaultHandler(handler).build();
// handler is gone here
PrometheusHttpServer rebuilt = server.toBuilder().setPort(0).build();
What did you expect to see?
The rebuilt server keeps the configured default handler. PrometheusHttpServer.toBuilder() documents "Returns a new PrometheusHttpServerBuilder with the same configuration as this instance."
What did you see instead?
defaultHandler is null on the returned builder. The package-private copy constructor PrometheusHttpServerBuilder(PrometheusHttpServerBuilder) (exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerBuilder.java line 48-57) copies 8 of the builder's 9 fields and omits defaultHandler. The sibling authenticator field is @Nullable, setter-only and passed to HTTPServer.builder() the same way, and it is copied.
The field was added in #6476 without a matching copy-constructor line; memoryMode had the same omission and was fixed later in #6799.
What version and what artifacts are you using?
Artifacts: opentelemetry-exporter-prometheus
Version: main @ 63ebd94
How did you reference these artifacts? implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
Environment
Compiler: Temurin 21
OS: N/A
Additional context
N/A
Describe the bug
PrometheusHttpServer.toBuilder()returns a builder that has lost theHttpHandlerset viaPrometheusHttpServerBuilder.setDefaultHandler(). A server rebuilt from that builder no longer serves metrics on/.Steps to reproduce
What did you expect to see?
The rebuilt server keeps the configured default handler.
PrometheusHttpServer.toBuilder()documents "Returns a newPrometheusHttpServerBuilderwith the same configuration as this instance."What did you see instead?
defaultHandlerisnullon the returned builder. The package-private copy constructorPrometheusHttpServerBuilder(PrometheusHttpServerBuilder)(exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerBuilder.javaline 48-57) copies 8 of the builder's 9 fields and omitsdefaultHandler. The siblingauthenticatorfield is@Nullable, setter-only and passed toHTTPServer.builder()the same way, and it is copied.The field was added in #6476 without a matching copy-constructor line;
memoryModehad the same omission and was fixed later in #6799.What version and what artifacts are you using?
Artifacts: opentelemetry-exporter-prometheus
Version: main @ 63ebd94
How did you reference these artifacts?
implementation("io.opentelemetry:opentelemetry-exporter-prometheus")Environment
Compiler: Temurin 21
OS: N/A
Additional context
N/A