Skip to content

Commit

Permalink
OpenTelemetry: NPE in HttpInstrumenterVertxTracer.RouteGetter when re…
Browse files Browse the repository at this point in the history
…quest got cancelled

Fixed NPE in HttpInstrumenterVertxTracer$RouteGetter when request got cancelled

Signed-off-by: Theodor Mihalache <[email protected]>
  • Loading branch information
tmihalac committed Jul 20, 2022
1 parent 1c93492 commit 61a0a6f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;

Expand Down Expand Up @@ -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 "/*";
}

Expand Down Expand Up @@ -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
Expand All @@ -246,7 +247,7 @@ public Long responseContentLengthUncompressed(final HttpRequest request, final H

@Override
public List<String> 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) {
Expand Down

0 comments on commit 61a0a6f

Please sign in to comment.