I have an ExtractVariables policy that does the below before a Statistics Collector policy. Get some elements from a JSON payload and store them into variables
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="ExtractVariables-Request-Statistics"> <DisplayName>ExtractVariables-Request-Statistics</DisplayName> <Source clearPayload="false">request</Source> <VariablePrefix>labelRequest</VariablePrefix> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <QueryParam name="format"> <Pattern ignoreCase="true">{labelFormat}</Pattern> </QueryParam> <JSONPayload> <Variable name="pickup"> <JSONPath>$.pickup</JSONPath> </Variable> <Variable name="distributionCenter"> <JSONPath>$.package.distributionCenter</JSONPath> </Variable> <Variable name="orderedProductId"> <JSONPath>$.package.orderedProductId</JSONPath> </Variable> </JSONPayload> </ExtractVariables>
And then the StatisticsCollector policy does this - move them to custom dimensions
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <StatisticsCollector async="false" continueOnError="false" enabled="true" name="StatisticsCollector-Request"> <DisplayName>StatisticsCollector-Request</DisplayName> <Properties/> <Statistics> <Statistic name="pickup" ref="labelRequest.pickup" type="string">null</Statistic> <Statistic name="orderedProductId" ref="labelRequest.orderedProductId" type="string">null</Statistic> <Statistic name="distributionCenter" ref="labelRequest.distributionCenter" type="string">null</Statistic> <Statistic name="labelformat" ref="labelRequest.labelFormat" type="string">null</Statistic> </Statistics> </StatisticsCollector>
Seems like basic stuff..though I can see the custom dimensions in the report, there is no value being set for any of the variables yet..it has been more than 2 hours since the first request was made with these dimensions..
looking at the trace, it seems the ExtractVariables did work correctly as i can see the variable values being populated but those variables are not getting populated in the Stat Collector (see screenshot).
What am I doing wrong here?
and here's a screenshot of the custom report where i am trying to find these custom dimensions.
I figured it out..,.it is because there's another statistics collector policy running from a post proxy flow hook which is overriding the data i'm recording from the policy in my proxy.
the flow hook is a company wide one that does nothing other than sending the correlation-id to the logs.
my stats policy collects a lot more api-specific variables along with the correlation id.
is it possible to add the policy somewhere where it runs after a post proxy flow hook so i can write a overarching stats collector policy?
No. It is not possible to
Maybe try wrapping the policy in the postclien flow hook so that it runs conditionally?
@Dino-at-Google can you provide some more insight into how to achieve this?
"Wrapping the policy in the postclient flow hook so that it runs conditionally"
Is it possible to add a condition to a statistics collector policy?
@Dino-at-Google nvm..i answered that question myself.. I need to write those conditions in the shared flows that's being called in the flow hooks.
yes, correct.