How to calculate processing time in apigee?

How to calculate processing time in apigee?  @kurtkanaskie 
@dchiesa1 

 

 

0 3 344
3 REPLIES 3

Did you check analytics ?Is it not helpful?

https://cloud.google.com/apigee/docs/api-platform/analytics/analytics-services-overview

There are few variable https://cloud.google.com/apigee/docs/api-platform/reference/variables-reference which you can use to calculate it but why not use oob analytics & extract the required information.

drop in proxy post flow..

try {
var systemTimeStamp = context.getVariable("system.timestamp");
var clientReceivedStartTimeStamp = context.getVariable("client.received.start.timestamp");
var targetReceivedEndTimeStamp = context.getVariable("target.received.end.timestamp");
var targetSentStartTimeStamp = context.getVariable("target.sent.start.timestamp");
var totalRequestTime = (systemTimeStamp-clientReceivedStartTimeStamp);
var totalTargetTime = (targetReceivedEndTimeStamp-targetSentStartTimeStamp);
} catch (error) {
context.setVariable("debug", error);
throw error;
}

If you want to just use the Analytics, the metrics are defined here https://cloud.google.com/apigee/docs/api-platform/analytics/analytics-reference

Ones of interest could be Request processing latency (time from when apigee receives the complete request, to start sending request to target ie request policy time), Response processing latency (time from target response received until it sends response back to consumer), and Total response time (which also includes the backend time along with time in Apigee)

Hi @devmego99,

If you are trying to calculate latencies for use in message logging, you can use something like this in a Shared Flow:

 

var request_start_time = context.getVariable('client.received.start.timestamp');
var target_start_time  = context.getVariable('target.sent.start.timestamp');
var target_end_time    = context.getVariable('target.received.end.timestamp');
// client.sent.end.timestamp is only available in PostClientFlow
var request_end_time   = context.getVariable('system.timestamp');

var total_time = request_end_time-request_start_time;
var total_target_time  = target_end_time-target_start_time;
var total_client_time  = total_time-total_target_time;