diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java index 176ca444d8b93..0ed0ef9764984 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java @@ -56,6 +56,7 @@ public CompletableResultCode shutdown() { static final class VertxHttpSender implements HttpSender { private static final String TRACES_PATH = "/v1/traces"; + private final String basePath; private final boolean compressionEnabled; private final Map headers; private final String contentType; @@ -69,6 +70,7 @@ static final class VertxHttpSender implements HttpSender { String contentType, Consumer clientOptionsCustomizer, Vertx vertx) { + this.basePath = determineBasePath(baseUri); this.compressionEnabled = compressionEnabled; this.headers = headersMap; this.contentType = contentType; @@ -81,13 +83,27 @@ static final class VertxHttpSender implements HttpSender { this.client = vertx.createHttpClient(httpClientOptions); } + private static String determineBasePath(URI baseUri) { + String path = baseUri.getPath(); + if (path.isEmpty() || path.equals("/")) { + return ""; + } + if (path.endsWith("/")) { // strip ending slash + path = path.substring(0, path.length() - 1); + } + if (!path.startsWith("/")) { // prepend leading slash + path = "/" + path; + } + return path; + } + @Override public void send(Consumer marshaler, int contentLength, Consumer onResponse, Consumer onError) { - client.request(HttpMethod.POST, TRACES_PATH) + client.request(HttpMethod.POST, basePath + TRACES_PATH) .onSuccess(new Handler<>() { @Override public void handle(HttpClientRequest request) {