From cd030d25b0e4f40f02ab63190faf0e6512d39cab Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Tue, 3 Aug 2021 10:35:23 +0200 Subject: [PATCH] EQL: correct time accounting for an intermediary response (#75804) This corrects the accounting of answer time reported in "took" attribute of an intermediary EQL async response. This has been reported as a negative value, since the delta mixes wall-clock time with VM time. (The confusion is favoured by Task#getStartTime() returning a wall-clock time, while Task#getStartTimeNanos() VM's time.) --- .../yamlRestTest/resources/rest-api-spec/test/eql/10_basic.yml | 1 + .../xpack/eql/plugin/TransportEqlSearchAction.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/eql/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/eql/10_basic.yml b/x-pack/plugin/eql/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/eql/10_basic.yml index 576e2db411864..1ff0f7a2c9cf4 100644 --- a/x-pack/plugin/eql/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/eql/10_basic.yml +++ b/x-pack/plugin/eql/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/eql/10_basic.yml @@ -309,6 +309,7 @@ setup: - is_true: id - set: {id: id} + - gte: {took: 0} - do: eql.get: diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/TransportEqlSearchAction.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/TransportEqlSearchAction.java index b2cf7f51e94b6..b6d8d167e65ba 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/TransportEqlSearchAction.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/TransportEqlSearchAction.java @@ -93,7 +93,7 @@ public void execute(EqlSearchRequest request, EqlSearchTask task, ActionListener @Override public EqlSearchResponse initialResponse(EqlSearchTask task) { return new EqlSearchResponse(EqlSearchResponse.Hits.EMPTY, - threadPool.relativeTimeInMillis() - task.getStartTime(), false, task.getExecutionId().getEncoded(), true, true); + TimeValue.nsecToMSec(System.nanoTime() - task.getStartTimeNanos()), false, task.getExecutionId().getEncoded(), true, true); } @Override