Skip to content

Commit

Permalink
Merge pull request #24169 from radcortez/fix-24102-2.7
Browse files Browse the repository at this point in the history
Fix URISyntaxException on Span name extraction
  • Loading branch information
gsmet committed Mar 8, 2022
2 parents a844979 + 137a70d commit 74a7f85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ void path() throws Exception {
assertEquals(server.getParentSpanId(), client.getSpanId());
}

@Test
void uri() throws Exception {
HttpResponse<Buffer> response = WebClient.create(vertx)
.get(uri.getPort(), uri.getHost(), "/hello?q=g\\+\\+&dataOnly=true")
.send()
.toCompletionStage().toCompletableFuture()
.get();

List<SpanData> spans = spanExporter.getFinishedSpanItems(2);
assertEquals(2, spans.size());
}

@ApplicationScoped
public static class HelloRouter {
@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.INSTRUMENTATION_NAME;
import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setContextSafe;

import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -303,9 +302,8 @@ private ServerSpanNameExtractor(
@Override
public String extract(final HttpRequest httpRequest) {
if (httpRequest instanceof HttpServerRequest) {
String path = URI.create(httpRequest.uri()).getPath();
if (path != null && path.length() > 1) {
return path.substring(1);
if (httpRequest.uri() != null && httpRequest.uri().length() > 1) {
return httpRequest.uri().substring(1);
} else {
return "HTTP " + httpRequest.method();
}
Expand Down

0 comments on commit 74a7f85

Please sign in to comment.