How can I get the total elapsed time using java script which is highlighted in the pic below . I have tried
var totalElapsedTime = (context.getVariable("system.timestamp")-context.getVariable("client.received.start.timestamp")). This is not working "system.timestamp" is empty.
Solved! Go to Solution.
Hmm, it's strange that "system.timestamp" is empty. that variable is always defined. Something else is wrong there. I think perhaps your arithmetic is not quite right.
Sometimes I add a JS policy into my Apigee Edge proxies that collects this information. Here's what I use.
// emitElapsed.js // ------------------------------------------------------------------ // // emit the elapsed time into response headers // var start, end, delta; start = context.getVariable('target.sent.start.timestamp'); end = context.getVariable('target.received.end.timestamp'); delta = Math.floor(end - start); context.proxyResponse.headers['X-time-target-elapsed'] = delta; start = context.getVariable('client.received.start.timestamp'); end = context.getVariable('system.timestamp'); delta = Math.floor(end - start); context.proxyResponse.headers['X-time-total-elapsed'] = delta;
This JS needs to be attached to the proxy response flow, ideally in postflow.
Hmm, it's strange that "system.timestamp" is empty. that variable is always defined. Something else is wrong there. I think perhaps your arithmetic is not quite right.
Sometimes I add a JS policy into my Apigee Edge proxies that collects this information. Here's what I use.
// emitElapsed.js // ------------------------------------------------------------------ // // emit the elapsed time into response headers // var start, end, delta; start = context.getVariable('target.sent.start.timestamp'); end = context.getVariable('target.received.end.timestamp'); delta = Math.floor(end - start); context.proxyResponse.headers['X-time-target-elapsed'] = delta; start = context.getVariable('client.received.start.timestamp'); end = context.getVariable('system.timestamp'); delta = Math.floor(end - start); context.proxyResponse.headers['X-time-total-elapsed'] = delta;
This JS needs to be attached to the proxy response flow, ideally in postflow.
Thanks @Dino
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |