From e9a3cf29610b2c04d2463cbf72f042e7b3787b6d Mon Sep 17 00:00:00 2001 From: Luigi Dell'Aquila Date: Fri, 5 Oct 2018 09:32:27 +0200 Subject: [PATCH] Add query execution time in HTTP response Resolves: #8579 --- .../protocol/http/command/post/OServerCommandPostCommand.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostCommand.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostCommand.java index fb071ea77cf..4272910868c 100755 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostCommand.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostCommand.java @@ -50,6 +50,7 @@ public boolean execute(final OHttpRequest iRequest, OHttpResponse iResponse) thr Object params = null; String mode = "resultset"; + long begin = System.currentTimeMillis(); if (iRequest.content != null && !iRequest.content.isEmpty()) { // CONTENT REPLACES TEXT if (iRequest.content.startsWith("{")) { @@ -102,6 +103,7 @@ public boolean execute(final OHttpRequest iRequest, OHttpResponse iResponse) thr result.getExecutionPlan().ifPresent(x -> additionalContent.put("executionPlan", x.toResult().toElement())); result.close(); + long elapsedMs = System.currentTimeMillis() - begin; String format = null; if (fetchPlan != null) { @@ -111,6 +113,7 @@ public boolean execute(final OHttpRequest iRequest, OHttpResponse iResponse) thr if (iRequest.getHeader("TE") != null) iResponse.setStreaming(true); + additionalContent.put("elapsedMs", elapsedMs); iResponse.writeResult(response, format, accept, additionalContent, mode); } finally {