Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Need Help with calculating the policy execution time from the debug session response

I have a requirement to calculate the time taken for a policy execution form the debug session response on APigeeX platform. 

When a debug session is created in apigeeX console the time taken for executing a  policy is displayed on the trace session, I want to calculate the same using the trace session data.

Screen Shot 2022-05-19 at 2.44.00 AM.png

I wanted to know how APigee is able to calculate the execution time.

Thanks in advance, for any help.

0 4 480
4 REPLIES 4

I'm not sure what you mean by the debug session response/trace session data on the Apigee X platform. Do you mean by exporting the debug session data?

Otherwise, there are variables in your API proxy that are available

https://cloud.google.com/apigee/docs/api-platform/reference/variables-reference#apigee

One of these is the apigee.metrics.policy.policy_name.timeTaken

I think that variable should be present in the debug session data export. Look for this: 

    <Point id="Execution">
        <DebugInfo>
            <Timestamp>04-03-22 19:57:34:861</Timestamp>
             ....
        </DebugInfo>
        ...
        <VariableAccess>
          ...
          <Set success="true" value="78894" name="apigee.metrics.policy.EV-ExtractVariable.timeTaken"/>
        </VariableAccess>
    </Point>

HI Dino, Thank you for looking into the problem, In Apigee debug trace data has the format you have specified. But in ApigeeX we get the response data in JSON format and the structure is also different, can you tell me the path  to pick up the value in ApigeeX debug response data.

Sure. 

In Apigee X or hybrid the debugsession data is different. Look for the timestamp fields. These are not computed "time taken" quantities, but just "time" quantities. The values are in milliseconds resolution, but strong format. In order to determine how much time a policy has taken, you will have to convert the timestamp strings to numeric values, then do some arithmetic - subtracting the prior timestamp from the current one.  Unfortunately the best resolution you can get with this is 1ms. You cannot tell if a policy took 500 usec or 74 usec etc.  It will result in "0 ms" for such policies. 

timestamps.png

I'm a little surprised that the Apigee X and hybrid timing information in the debug sessions is not more precise. I'll look into that.