diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java index 0e21f0d2bdbc33..a686d4e6892886 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java @@ -1,9 +1,6 @@ package io.quarkus.opentelemetry.runtime.tracing.vertx; -import static io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteSource.FILTER; -import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_CLIENT_IP; -import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.INSTRUMENTATION_NAME; - +import java.util.Collections; import java.util.List; import java.util.function.BiConsumer; @@ -39,6 +36,10 @@ import io.vertx.core.spi.observability.HttpResponse; import io.vertx.core.spi.tracing.TagExtractor; +import static io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteSource.FILTER; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_CLIENT_IP; +import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.INSTRUMENTATION_NAME; + class HttpInstrumenterVertxTracer implements InstrumenterVertxTracer { private final Instrumenter serverInstrumenter; private final Instrumenter clientInstrumenter; @@ -151,7 +152,7 @@ public String get(final io.opentelemetry.context.Context context, final HttpRequ return route; } - if (HttpResponseStatus.NOT_FOUND.code() == response.statusCode()) { + if (response != null && HttpResponseStatus.NOT_FOUND.code() == response.statusCode()) { return "/*"; } @@ -231,12 +232,12 @@ public Long requestContentLengthUncompressed(final HttpRequest request, final Ht @Override public Integer statusCode(final HttpRequest request, final HttpResponse response) { - return response.statusCode(); + return response != null ? response.statusCode() : 499; } @Override public Long responseContentLength(final HttpRequest request, final HttpResponse response) { - return getContentLength(response.headers()); + return response != null ? getContentLength(response.headers()) : 0; } @Override @@ -246,7 +247,7 @@ public Long responseContentLengthUncompressed(final HttpRequest request, final H @Override public List responseHeader(final HttpRequest request, final HttpResponse response, final String name) { - return response.headers().getAll(name); + return response != null ? response.headers().getAll(name) : Collections.emptyList(); } private static Long getContentLength(final MultiMap headers) {