Closed Jithesh-Menon closed 1 year ago
Please share a minimal repro application demonstrating the issue. its not clear how are you concluding "not taking effect". code sample, along with the actual queries used to validate if sampling is done would help us understand the question better.
Hi @cijothomas ,
In my query I have explained what I am trying to do with code sample and the query I used to see the results in app insights.
I was trying to reduce the traffic into app insights by excluding the "Dependency". I have also tried the same approach for "Request" as well. As I mentioned in my query, I am using a .Net Framework 4.7.2 application and trying to make the best out of app insights settings options.
Pasting the code approach I did from the query section for your convenience.
Approach:- Configure adaptive sampling in code EnableDependencyTrackingTelemetryModule and EnableAdaptiveSampling settings set to true
var telemetryConfig = serviceProvider.GetRequiredService<TelemetryConfiguration>();
var builder = telemetryConfig.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes
// DependencyTelemetry from being subject to sampling.
builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
builder.Build();
Irrespective of the sampling exclude types settings I provided Dependency/Request are still post details into app insights for the cloud role instance (my machine) that the app is running on.
Kindly advise.
Thank you
app insights by excluding the "Dependency"
ExcludedTypes in UseAdaptiveSampling - means just the opposite. i.e Dependency items are NOT considered for sampling, means they are always sent. You want the opposite, based on your description.
Thank you!
So, how could we ensure the Dependency is not considered for sampling while it is present in application insights logs.
Could you please advise?
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes // DependencyTelemetry from being subject to sampling. builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes // DependencyTelemetry from being subject to sampling. builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
This code will ensure Dependency is being excluded from Sampling. But how could we verify it got excluded..? Could you please provide a clarification on that..?
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes // DependencyTelemetry from being subject to sampling. builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
This code will ensure Dependency is being excluded from Sampling. But how could we verify it got excluded..? Could you please provide a clarification on that..?
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.
i tried to exclude the following types in ApplicationInsights.config from sampling
after more than 1 day i run the query to confirm, request type is still sampled.
anyone know if there is anything wrong? thank you
List of NuGet packages and version that you are using: Microsoft.ApplicationInsights 2.20.0 Microsoft.ApplicationInsights.WorkerService 2.20.0 and Microsoft.Extensions.DependencyInjection 6.0.0 Microsoft.Extensions.DependencyInjection.Abstractions 6.0.0 Microsoft.Identity.Client.Desktop 4.41.0 System.Runtime.CompilerServices.Unsafe 6.0.0
Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file): NetFramework4.7.2
Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.): Windows
Describe the bug
Attempting to use the default setting of EnableAdaptiveSampling - true and setting exclude types has not had the desired effect. i.e, trying to exclude the "Dependency" from the app insights logging [and also tried with "Request"] still logs details into app insights for the cloud role instance (my machine) that the app is running on.
Referred the below links :- Configuring adaptive sampling for ASP.NET applications https://github.com/toddkitta/azure-content/blob/master/articles/application-insights/app-insights-sampling.md
Approach:- Configure adaptive sampling in code EnableDependencyTrackingTelemetryModule and EnableAdaptiveSampling settings set to true
But the above approach didn't reflect and does provide results for KQL query.
Please check and advise.
Thank you.