I need to retain all telemetry since we use this for analytics.
According to this article I can run the following Analytics query to determine the rate of sampling:
requests
| where timestamp > ago(1d)
| summarize 100/avg(itemCount) by bin(timestamp, 1h)
| render areachart
The results indicate some heavily sampling, especially during the day where only around 1 in 10 items are retained:
What confuses me is that the Azure Portal insdicates that sampling is set to 100%:
Perhaps this only reflects Ingestion sampling? Adaptive sampling could still be occurring on the server.
How do I disable sampling completely using the ASP.NET Core libraries for Application Insights? (i.e. Microsoft.ApplicationInsights.AspNetCore 1.0.2)
Currently, this is these are the only configuration I can find and there isn't anything on sampling:
var appInsightsConfiguration = new ConfigurationBuilder()
.AddApplicationInsightsSettings(
developerMode: false,
instrumentationKey: Configuration["ApplicationInsights:InstrumentationKey"])
.Build();
services.AddApplicationInsightsTelemetry(appInsightsConfiguration);
To switch off adaptive sampling, remove the AdaptiveSamplingTelemetryProcessor node(s) from ApplicationInsights.
It is enabled by default. To disable it within Visual Studio, you may want to use the actual Visual Studio settings to disable it. To disable it go to “TOOLS –> Options –> Projects and Solutions –> Web Projects” and check “Disable local Application Insights for Asp.Net Core web projects.”
Open your project in Visual Studio. Go to Project > Add Application Insights Telemetry. Choose Azure Application Insights, then select Next. Choose your subscription and Application Insights instance (or create a new instance with Create new), then select Next.
The Application Insights SDK and instrumentation is designed to be extremely lightweight and have minimal impact on the performance of your application.
You can disable sampling by using the ApplicationInsightsServiceOptions class.
A usage example:
var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions();
aiOptions.EnableAdaptiveSampling = false;
services.AddApplicationInsightsTelemetry(Configuration, aiOptions);
See more details about sampling in the Application Insights ASP.NET Core Github documentation page.
Hope this helps,
Asaf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With