2222import io .smallrye .mutiny .vertx .UniHelper ;
2323import io .vertx .core .Future ;
2424import io .vertx .core .http .HttpServerRequest ;
25- import okhttp3 .Call ;
26- import okhttp3 .Callback ;
27- import okhttp3 .Interceptor ;
28- import okhttp3 .MediaType ;
29- import okhttp3 .OkHttpClient ;
30- import okhttp3 .Request ;
31- import okhttp3 .RequestBody ;
32- import okhttp3 .Response ;
25+ import okhttp3 .*;
3326import org .apache .commons .io .IOUtils ;
3427import org .commonjava .util .gateway .config .ProxyConfiguration ;
3528import org .commonjava .util .gateway .config .ServiceConfig ;
@@ -310,8 +303,6 @@ public Uni<Response> enqueue()
310303 }
311304
312305 return UniHelper .toUni ( Future .future ( ( p ) -> {
313- logger .debug ( "Starting upstream request..." );
314-
315306 Span span = otel .newClientSpan ( "okhttp" ,
316307 requestBuilder .build ().method () + ":" + serviceConfig .host + ":"
317308 + serviceConfig .port );
@@ -322,10 +313,14 @@ public Uni<Response> enqueue()
322313
323314 Call call = callClient .newCall ( requestBuilder .build () );
324315
316+ final String timestamp = System .currentTimeMillis () + "." + System .nanoTime (); // to identify the beginning/ending log message
317+ final HttpUrl url = call .request ().url ();
318+ final String method = call .request ().method ();
319+ logger .info ( "Starting upstream request: [{}] {} ({})" , method , url , timestamp );
325320
326- span .setAttribute ( SemanticAttributes .HTTP_METHOD , call . request (). method () );
327- span .setAttribute ( SemanticAttributes .HTTP_HOST , call . request (). url () .host () );
328- span .setAttribute ( SemanticAttributes .HTTP_URL , call . request (). url () .url ().toExternalForm () );
321+ span .setAttribute ( SemanticAttributes .HTTP_METHOD , method );
322+ span .setAttribute ( SemanticAttributes .HTTP_HOST , url .host () );
323+ span .setAttribute ( SemanticAttributes .HTTP_URL , url .url ().toExternalForm () );
329324
330325 call .enqueue ( new Callback ()
331326 {
@@ -341,7 +336,7 @@ public void onFailure( @NotNull Call call, @NotNull IOException e )
341336 scope .close ();
342337 span .end ();
343338
344- logger .trace ( "Failed: " + call . request (). url ( ), e );
339+ logger .warn ( String . format ( "Failed: [%s] %s (%s)" , method , url , timestamp ), e );
345340 p .fail ( e );
346341 }
347342
@@ -357,7 +352,7 @@ public void onResponse( @NotNull Call call, @NotNull Response response )
357352 scope .close ();
358353 span .end ();
359354
360- logger .trace ( "Success: " + call . request (). url () + " -> " + response .code () );
355+ logger .info ( "Success: [{}] {} -> {} ({})" , method , url , response .code (), timestamp );
361356 p .complete ( response );
362357 }
363358 } );
0 commit comments