microsoft / ApplicationInsights-dotnet

ApplicationInsights-dotnet
MIT License
565 stars 287 forks source link

Adaptive Sampling Default SetLastObservedSamplingPercentage #2914

Open czb182 opened 2 weeks ago

czb182 commented 2 weeks ago

Why is SetLastObservedSamplingPercentage only called for Request type telemetry by default?

I'm customized adaptive sampling, so I have disabled in config and setting up in code per this documentation https://learn.microsoft.com/en-us/azure/azure-monitor/app/sampling-classic-api#configure-sampling-settings

I was taking the default setup from this repo to build upon it.

Notice that the default adaptive sampling uses a sampling callback to setup lastobserved for request telemetry https://github.com/microsoft/ApplicationInsights-dotnet/blob/e34286b4c8175d7ea47f9227c5b981d661cac470/NETCORE/src/Shared/Implementation/TelemetryConfigurationOptionsSetup.cs#L332

this is not shown in documentation, and I gather its to increase accuracy of sampling, but why not set last observed for all types included in sampling?

Not sure if this is issue or not. Or maybe because sampling seems to be done at the operation level (seemingly) you only need to set for one type?