File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
java/sample-apps/okhttp/src/main/java/io/opentelemetry/lambda/sampleapps/okhttp Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 88import io .opentelemetry .instrumentation .okhttp .v3_0 .OkHttpTelemetry ;
99import java .io .IOException ;
1010import java .io .UncheckedIOException ;
11+ import okhttp3 .Call ;
1112import okhttp3 .OkHttpClient ;
1213import okhttp3 .Request ;
1314import 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 ) {
You can’t perform that action at this time.
0 commit comments