Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#### Exporters

* Prometheus: Fix `PrometheusHttpServer.toBuilder()` dropping the configured default handler
([#8619](https://github.com/open-telemetry/opentelemetry-java/pull/8619))
* Logging: Output event name in `SystemOutLogRecordExporter`
([#8609](https://github.com/open-telemetry/opentelemetry-java/pull/8609))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public final class PrometheusHttpServerBuilder {
this.metricReaderBuilder = new PrometheusMetricReaderBuilder(builder.metricReaderBuilder);
this.executor = builder.executor;
this.memoryMode = builder.memoryMode;
this.defaultHandler = builder.defaultHandler;
this.defaultAggregationSelector = builder.defaultAggregationSelector;
this.authenticator = builder.authenticator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.linecorp.armeria.common.RequestHeaders;
import com.sun.net.httpserver.Authenticator;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpPrincipal;
import io.github.netmikey.logunit.api.LogCapturer;
import io.opentelemetry.api.common.Attributes;
Expand Down Expand Up @@ -755,6 +756,9 @@ public Result authenticate(HttpExchange exchange) {
};
builder.setAuthenticator(authenticator);

HttpHandler defaultHandler = exchange -> {};
builder.setDefaultHandler(defaultHandler);

PrometheusHttpServer httpServer = builder.build();
PrometheusHttpServerBuilder fromOriginalBuilder = httpServer.toBuilder();
httpServer.close();
Expand All @@ -765,6 +769,7 @@ public Result authenticate(HttpExchange exchange) {
.hasFieldOrPropertyWithValue("executor", executor)
.hasFieldOrPropertyWithValue("prometheusRegistry", prometheusRegistry)
.hasFieldOrPropertyWithValue("authenticator", authenticator)
.hasFieldOrPropertyWithValue("defaultHandler", defaultHandler)
.extracting("metricReaderBuilder")
.usingRecursiveComparison()
.isEqualTo(
Expand Down
Loading