Skip to content

Commit 70f85cd

Browse files
committed
Suppressing auto instrumentation
1 parent 5e5fbeb commit 70f85cd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

opamp-client/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ otelJava.moduleName.set("io.opentelemetry.contrib.opamp.client")
1616
dependencies {
1717
implementation("com.squareup.okhttp3:okhttp")
1818
implementation("com.github.f4b6a3:uuid-creator")
19+
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
1920
annotationProcessor("com.google.auto.value:auto-value")
2021
compileOnly("com.google.auto.value:auto-value-annotations")
2122
testImplementation("org.mockito:mockito-inline")

opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/connectivity/http/OkHttpSender.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.opamp.client.internal.connectivity.http;
77

8+
import io.opentelemetry.api.internal.InstrumentationUtil;
89
import java.io.IOException;
910
import java.io.InputStream;
1011
import java.util.concurrent.CompletableFuture;
@@ -13,6 +14,7 @@
1314
import okhttp3.Callback;
1415
import okhttp3.MediaType;
1516
import okhttp3.OkHttpClient;
17+
import okhttp3.Request;
1618
import okhttp3.RequestBody;
1719
import okio.BufferedSink;
1820

@@ -45,8 +47,14 @@ public CompletableFuture<Response> send(BodyWriter writer, int contentLength) {
4547
RequestBody body = new RawRequestBody(writer, contentLength, MEDIA_TYPE);
4648
builder.post(body);
4749

50+
InstrumentationUtil.suppressInstrumentation(() -> doSendRequest(builder.build(), future));
51+
52+
return future;
53+
}
54+
55+
private void doSendRequest(Request request, CompletableFuture<Response> future) {
4856
client
49-
.newCall(builder.build())
57+
.newCall(request)
5058
.enqueue(
5159
new Callback() {
5260
@Override
@@ -59,8 +67,6 @@ public void onFailure(Call call, IOException e) {
5967
future.completeExceptionally(e);
6068
}
6169
});
62-
63-
return future;
6470
}
6571

6672
private static class OkHttpResponse implements Response {

0 commit comments

Comments
 (0)