2121package com .spotify .github .v3 .clients ;
2222
2323import com .fasterxml .jackson .core .type .TypeReference ;
24- import com .spotify .github .tracing .Span ;
25- import com .spotify .github .tracing .Tracer ;
2624import com .spotify .github .async .Async ;
2725import com .spotify .github .jackson .Json ;
26+ import com .spotify .github .tracing .Span ;
27+ import com .spotify .github .tracing .Tracer ;
2828import com .spotify .github .v3 .Team ;
2929import com .spotify .github .v3 .User ;
3030import com .spotify .github .v3 .checks .AccessToken ;
4040import com .spotify .github .v3 .repos .*;
4141import okhttp3 .*;
4242import org .apache .commons .io .FileUtils ;
43+ import org .jetbrains .annotations .NotNull ;
4344import org .slf4j .Logger ;
4445import org .slf4j .LoggerFactory ;
4546
@@ -137,6 +138,7 @@ public class GitHubClient {
137138 private final Optional <URI > graphqlUrl ;
138139 private final Json json = Json .create ();
139140 private final OkHttpClient client ;
141+ private Call .Factory callFactory ;
140142 private final String token ;
141143
142144 private final byte [] privateKey ;
@@ -909,8 +911,10 @@ private AccessToken generateInstallationToken(final String jwtToken, final int i
909911
910912 private CompletableFuture <Response > call (final Request request ) {
911913 try (Span span = tracer .span (request )) {
912- Request tracedRequest = span .decorateRequest (request );
913- final Call call = client .newCall (tracedRequest );
914+ if (this .callFactory == null ) {
915+ this .callFactory = this .tracer .createTracedClient (this .client );
916+ }
917+ final Call call = this .callFactory .newCall (request );
914918
915919 final CompletableFuture <Response > future = new CompletableFuture <>();
916920
@@ -920,12 +924,12 @@ private CompletableFuture<Response> call(final Request request) {
920924 call .enqueue (
921925 new Callback () {
922926 @ Override
923- public void onFailure (final Call call , final IOException e ) {
927+ public void onFailure (@ NotNull final Call call , final IOException e ) {
924928 future .completeExceptionally (e );
925929 }
926930
927931 @ Override
928- public void onResponse (final Call call , final Response response ) {
932+ public void onResponse (@ NotNull final Call call , final Response response ) {
929933 processPossibleRedirects (response , redirected )
930934 .handle (
931935 (res , ex ) -> {
0 commit comments