Skip to content

Commit

Permalink
Fix Incorrect Time Math in MockTransport (elastic#42595)
Browse files Browse the repository at this point in the history
* Fix Incorrect Time Math in MockTransport

* The timeunit here must be nanos for the current time (we even convert it accordingly in the logging)
* Also, changed the log message when dumping stack traces a little to make it easier to grep for (otherwise it's the same as the message on unregister)
  • Loading branch information
original-brownbear authored May 28, 2019
1 parent 5f651f4 commit e97bee6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ private void maybeLogElapsedTime(long startTime) {

private void logLongRunningExecutions() {
for (Map.Entry<Thread, Long> entry : registry.entrySet()) {
final long elapsedTime = threadPool.relativeTimeInMillis() - entry.getValue();
if (elapsedTime > WARN_THRESHOLD) {
final long elapsedTimeInNanos = threadPool.relativeTimeInNanos() - entry.getValue();
if (elapsedTimeInNanos > WARN_THRESHOLD) {
final Thread thread = entry.getKey();
logger.warn("Slow execution on network thread [{}] [{} milliseconds]: \n{}", thread.getName(),
TimeUnit.NANOSECONDS.toMillis(elapsedTime),
logger.warn("Potentially blocked execution on network thread [{}] [{} milliseconds]: \n{}", thread.getName(),
TimeUnit.NANOSECONDS.toMillis(elapsedTimeInNanos),
Arrays.stream(thread.getStackTrace()).map(Object::toString).collect(Collectors.joining("\n")));
}
}
Expand Down

0 comments on commit e97bee6

Please sign in to comment.