Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take OTel exporter endpoint path into account #35503

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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