21
21
package com .spotify .github .v3 .clients ;
22
22
23
23
import com .fasterxml .jackson .core .type .TypeReference ;
24
- import com .spotify .github .tracing .Span ;
25
- import com .spotify .github .tracing .Tracer ;
26
24
import com .spotify .github .async .Async ;
27
25
import com .spotify .github .jackson .Json ;
26
+ import com .spotify .github .tracing .Span ;
27
+ import com .spotify .github .tracing .Tracer ;
28
28
import com .spotify .github .v3 .Team ;
29
29
import com .spotify .github .v3 .User ;
30
30
import com .spotify .github .v3 .checks .AccessToken ;
40
40
import com .spotify .github .v3 .repos .*;
41
41
import okhttp3 .*;
42
42
import org .apache .commons .io .FileUtils ;
43
+ import org .jetbrains .annotations .NotNull ;
43
44
import org .slf4j .Logger ;
44
45
import org .slf4j .LoggerFactory ;
45
46
@@ -137,6 +138,7 @@ public class GitHubClient {
137
138
private final Optional <URI > graphqlUrl ;
138
139
private final Json json = Json .create ();
139
140
private final OkHttpClient client ;
141
+ private Call .Factory callFactory ;
140
142
private final String token ;
141
143
142
144
private final byte [] privateKey ;
@@ -909,8 +911,10 @@ private AccessToken generateInstallationToken(final String jwtToken, final int i
909
911
910
912
private CompletableFuture <Response > call (final Request request ) {
911
913
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 );
914
918
915
919
final CompletableFuture <Response > future = new CompletableFuture <>();
916
920
@@ -920,12 +924,12 @@ private CompletableFuture<Response> call(final Request request) {
920
924
call .enqueue (
921
925
new Callback () {
922
926
@ Override
923
- public void onFailure (final Call call , final IOException e ) {
927
+ public void onFailure (@ NotNull final Call call , final IOException e ) {
924
928
future .completeExceptionally (e );
925
929
}
926
930
927
931
@ Override
928
- public void onResponse (final Call call , final Response response ) {
932
+ public void onResponse (@ NotNull final Call call , final Response response ) {
929
933
processPossibleRedirects (response , redirected )
930
934
.handle (
931
935
(res , ex ) -> {
0 commit comments