Skip to content

Commit

Permalink
Use ms for latency in log (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhan1 authored Nov 27, 2023
1 parent ba1809c commit d91b214
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ public Uni<Response> enqueue()
Call call = callClient.newCall( requestBuilder.build() );

final long nano = System.nanoTime();
final String timestamp = System.currentTimeMillis() + "." + nano; // to identify the beginning/ending log message
final long mill = System.currentTimeMillis();
final String timestamp = mill + "." + nano; // to identify the beginning/ending log message
final HttpUrl url = call.request().url();
final String method = call.request().method();
logger.info( "Starting upstream request: [{}] {} ({})", method, url, timestamp );
Expand All @@ -337,8 +338,8 @@ public void onFailure( @NotNull Call call, @NotNull IOException e )
scope.close();
span.end();

logger.warn( String.format("Failed: [%s] %s (%s), latency: %s", method, url, timestamp,
System.nanoTime() - nano), e );
logger.warn( String.format("Failed: [%s] %s (%s), latency: %sms", method, url, timestamp,
System.currentTimeMillis() - mill), e );
p.fail( e );
}

Expand All @@ -354,8 +355,8 @@ public void onResponse( @NotNull Call call, @NotNull Response response )
scope.close();
span.end();

logger.info( "Success: [{}] {} -> {} ({}), latency: {}", method, url, response.code(), timestamp,
System.nanoTime() - nano );
logger.info( "Success: [{}] {} -> {} ({}), latency: {}ms", method, url, response.code(), timestamp,
System.currentTimeMillis() - mill );
p.complete( response );
}
} );
Expand Down

0 comments on commit d91b214

Please sign in to comment.