Skip to content

Commit d91b214

Browse files
authored
Use ms for latency in log (#85)
1 parent ba1809c commit d91b214

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/commonjava/util/gateway/util/WebClientAdapter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ public Uni<Response> enqueue()
314314
Call call = callClient.newCall( requestBuilder.build() );
315315

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

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

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

357-
logger.info( "Success: [{}] {} -> {} ({}), latency: {}", method, url, response.code(), timestamp,
358-
System.nanoTime() - nano );
358+
logger.info( "Success: [{}] {} -> {} ({}), latency: {}ms", method, url, response.code(), timestamp,
359+
System.currentTimeMillis() - mill );
359360
p.complete( response );
360361
}
361362
} );

0 commit comments

Comments
 (0)