Skip to content

Commit ba1809c

Browse files
authored
Merge pull request #84 from ruhan1/master-latency
Print latency in the log
2 parents 6640554 + 5fea2cd commit ba1809c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ public Uni<Response> enqueue()
313313

314314
Call call = callClient.newCall( requestBuilder.build() );
315315

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

339-
logger.warn( String.format("Failed: [%s] %s (%s)", method, url, timestamp), e );
340+
logger.warn( String.format("Failed: [%s] %s (%s), latency: %s", method, url, timestamp,
341+
System.nanoTime() - nano), e );
340342
p.fail( e );
341343
}
342344

@@ -352,7 +354,8 @@ public void onResponse( @NotNull Call call, @NotNull Response response )
352354
scope.close();
353355
span.end();
354356

355-
logger.info( "Success: [{}] {} -> {} ({})", method, url, response.code(), timestamp );
357+
logger.info( "Success: [{}] {} -> {} ({}), latency: {}", method, url, response.code(), timestamp,
358+
System.nanoTime() - nano );
356359
p.complete( response );
357360
}
358361
} );

0 commit comments

Comments
 (0)