Skip to content

Commit

Permalink
Merge pull request #26779 from tmihalac/issue_26764
Browse files Browse the repository at this point in the history
OpenTelemetry: NPE in HttpInstrumenterVertxTracer.RouteGetter when request got cancelled
  • Loading branch information
gsmet authored Jul 25, 2022
2 parents a00af11 + 0322976 commit b2574a8
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() : null;
}

@Override
public Long responseContentLength(final HttpRequest request, final HttpResponse response) {
return getContentLength(response.headers());
return response != null ? getContentLength(response.headers()) : null;
}

@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 b2574a8

Please sign in to comment.