Execution time of the policies in a proxy

4 5 2,961

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.

Comments
Not applicable

Is this available in 15.07 ? @sriki77

Not applicable

@sriki77 : Thanks for the article. That's a cool thing. Just want to highlight that in documentation

it is saying api_proxy_name instead of policy_name. Please check.

apigee.metrics.policy.{api_proxy_name}.timeTaken

Variable references

jonesfloyd
Staff

Thanks, @Vipul Agarwal! Docs are fixed.

yves_scotto
Participant I

Hello I try to log timeTaken by a Callout Policy (name : CalloutOIDC).

I tried to set a global variable in an AssignVariable policy just after calling my Callout policy.

<AssignVariable> <Name>log_var_oidc_time</Name> <Ref>apigee.metrics.policy.CalloutOIDC.timeTaken</Ref> </AssignVariable>

But it doesn't work 😞

Any idea?

Thank you

Not applicable

The scope of apigee.metrics.policy..timeTaken is only within the policy. For eg If I want to know how much time a service callout is taking. There is no way right now that I can assign the value of the time taken to a variable within a service callout. Any thoughts ??

Version history
Last update:
‎07-26-2015 10:10 PM
Updated by: