Skip to content

Commit 912a553

Browse files
committed
fix build
1 parent 3e1a3f7 commit 912a553

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

java/sample-apps/okhttp/src/main/java/io/opentelemetry/lambda/sampleapps/okhttp/OkHttpRequestHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTelemetry;
99
import java.io.IOException;
1010
import java.io.UncheckedIOException;
11+
import okhttp3.Call;
1112
import okhttp3.OkHttpClient;
1213
import okhttp3.Request;
1314
import okhttp3.Response;
@@ -24,15 +25,14 @@ public APIGatewayProxyResponseEvent handleRequest(
2425
APIGatewayProxyRequestEvent input, Context context) {
2526
logger.info("Serving lambda request.");
2627

27-
OkHttpClient client =
28-
new OkHttpClient.Builder()
29-
.addInterceptor(OkHttpTelemetry.create(GlobalOpenTelemetry.get()).newInterceptor())
30-
.build();
28+
OkHttpClient baseClient = new OkHttpClient();
29+
Call.Factory callFactory =
30+
OkHttpTelemetry.create(GlobalOpenTelemetry.get()).newCallFactory(baseClient);
3131

3232
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent();
3333

3434
Request request = new Request.Builder().url("https://aws.amazon.com/").build();
35-
try (Response okhttpResponse = client.newCall(request).execute()) {
35+
try (Response okhttpResponse = callFactory.newCall(request).execute()) {
3636
response.setBody(
3737
"Hello lambda - fetched " + okhttpResponse.body().string().length() + " bytes.");
3838
} catch (IOException e) {

0 commit comments

Comments
 (0)