Skip to content

Commit

Permalink
Take OTel exporter endpoint path into account
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Aug 23, 2023
1 parent ba493f7 commit 3511999
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> headers;
private final String contentType;
Expand All @@ -69,6 +70,7 @@ static final class VertxHttpSender implements HttpSender {
String contentType,
Consumer<HttpClientOptions> clientOptionsCustomizer,
Vertx vertx) {
this.basePath = determineBasePath(baseUri);
this.compressionEnabled = compressionEnabled;
this.headers = headersMap;
this.contentType = contentType;
Expand All @@ -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<OutputStream> marshaler,
int contentLength,
Consumer<Response> onResponse,
Consumer<Throwable> onError) {

client.request(HttpMethod.POST, TRACES_PATH)
client.request(HttpMethod.POST, basePath + TRACES_PATH)
.onSuccess(new Handler<>() {
@Override
public void handle(HttpClientRequest request) {
Expand Down

0 comments on commit 3511999

Please sign in to comment.