Add response time in api response to test latency (#3465)

* Add response time in api response to test latency

* linting fixes

Co-authored-by: Eric Reynolds <eric.reynolds@konghq.com>
This commit is contained in:
Amaan Iqbal
2021-06-12 05:02:21 +05:30
committed by Opender Singh
parent 1147f273d8
commit 566ca93bad

View File

@@ -4,6 +4,10 @@ import { send } from '../network/network';
import { getBodyBuffer } from '../models/response';
import * as plugins from '../plugins';
function toMs(num) {
return Math.round(num * 1000) / 1000;
}
export async function getSendRequestCallbackMemDb(environmentId, memDB) {
// Initialize the DB in-memory and fill it with data if we're given one
await db.init(
@@ -55,6 +59,7 @@ async function sendAndTransform(requestId, environmentId) {
statusMessage: res.statusMessage,
data: bodyBuffer ? bodyBuffer.toString('utf8') : undefined,
headers: headersObj,
responseTime: toMs(res.elapsedTime),
};
} finally {
plugins.clearIgnores();