Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tell Application Insights to down-sample telemetry, but not exceptions?

I'd like to switch to using Application Insights for logging etc. I know I'm going to need to use sampling on my telemetry data, to stay within the free plan. However, I want to be able to see all event sequences that led to an exception being thrown, so I can reproduce them.

Does Application Insights come with something like this built in? And if not, is there some way I can write a custom sampler which produces the desired behaviour? E.g.

class CustomSampler : ITelemetrySampler
like image 913
Andrew Williamson Avatar asked Jan 05 '23 18:01

Andrew Williamson


1 Answers

There is the ExcludeTypes property in version 2.2.0 of the AdaptiveSamplingTelemetryProcessor.

<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
  <MaxTelemetryItemsPerSecond>499</MaxTelemetryItemsPerSecond>
  <ExcludedTypes>Exception</ExcludedTypes>
</Add>

From the release notes of 2.2.0-beta1

Telemetry types can be excluded from sampling by specifying the ExcludedTypes property (Add ExcludedTypes element under AdaptiveSampling telemetry processor node with ';'-separated list. Possible types are "Dependency", "Event", "Exception", "PageView", "Request", "Trace").

https://github.com/Microsoft/ApplicationInsights-dotnet/blob/v2.2.0/src/TelemetryChannels/ServerTelemetryChannel/Shared/AdaptiveSamplingTelemetryProcessor.cs#L67

like image 150
James Davis - MSFT Avatar answered Jan 12 '23 01:01

James Davis - MSFT