A lot of users are interested in the time taken by each of the policies during proxy execution.
Typically this calculated by surrounding the proxy whose execution time is required by 2 other policies.
A policy before to set the start time and a policy after to determine the end time + calculate the time difference. These surrounding policies are usually JS policies, which by the end, expose the time taken by the policy of interest as a variable.
With the latest release of Edge (above effort is not necessary), every policy exposes a variable after its execution which has the execution time of the policy. The variable name has the format
apigee.metrics.policy.<policy name>.timeTaken
The value of this variable is in nano-seconds; that is execution time of the policy in nano-seconds. This variable is useful in logging or any other activity.
As evident, if the policy repeats in the execution flow, the variable value will be overwritten. The value will reflect the time taken during the latest execution. Hence it is good practice to copy the value of variable immediately after the first policy to another variable in such scenarios.
Please provide feedback or report issues if any.