Skip to content

Fixed Rate Sampling v2 (2.x)

Trask Stalnaker edited this page Jan 20, 2021 · 1 revision

From the upcoming Beta SDK Release we would have the Telemetry Processor based Sampling Mechanism for Fixed Rate Telemetry Sampling. It provides a more cleaner way to sample and adds more flexibility. The new way of sampling would require users to add following lines in their ApplicationInsights.xml File:

In the ApplicationInsights.xml file add the following:

    <TelemetryProcessors>
        <BuiltInProcessors>
            <Processor type="FixedRateSamplingTelemetryProcessor">
                <Add name="SamplingPercentage" value="50" />
                <ExcludedTypes>
                    <ExcludedType>Request</ExcludedType>
                </ExcludedTypes>
                <IncludedTypes>
                    <IncludedType>Request</IncludedType>
                    <IncludedType>Trace</IncludedType>
                    <IncludedType>Dependency</IncludedType>
                    <IncludedType>Exception</IncludedType>
                </IncludedTypes>
            </Processor>
        </BuiltInProcessors>
    </TelemetryProcessors>

Where Included and Excluded Type can take following values : Dependency, Event, Exception, PageView, Request and Trace.

The sampling percentage should be of the form 100 / N. Avoiding to follow this would lead to unexpected behavior on Portal and Analytics. Some of the valid percentages can be (50, 33, 25, 20, 10 .....)

The sampling mechanism will be based on OperationId. All telemetry items having same OperationId would either be sampled in or sampled out based on sampling percentage specified by the user.

Some telemetry type is by default not subject to sampling: PerformanceCounterTelemetry, MetricTelemetry, SessionStateTelemetry.

How to verify sampling is active :

  1. Go to Analytics Portal
  2. Execute the following query : requests | summarize count(), sum(itemCount)
  3. If there is a difference between the above two and the ratio is as expected then sampling is in place.

We highly recommend the usage of this to have cleaner correlated telemetry being stored for analysis!