We have a requirement where we have to send the elapsed time as a part of the response from proxy.
After my research and analysis I used a JS as the last execution policy in the target endpoint to find the difference between the (current timestamp - client.received.start.timestamp) and used it in the response.
PS: I know we will not be able to get the actual elaspsed time but then the closest should be fine.
Please share if there is better solution which can be implemented to achieve this.
This will give you the total time elapsed including wait time on target and time it takes for client to send all data in:
client.sent.end.timestamp - client.received.start.timestamp
If you are only interested in processing time excluding client data in/out:
client.send.start.timestamp - client.received.end.timestamp
These variables (and many more) are explained here: http://apigee.com/docs/api-services/reference/variables-reference