Closed
Description
openedon Nov 4, 2019
Sometimes uncaught exceptions from a netcore 2.2 WebApi seem to be sampled out. Not all expected error logs can be found in Azure Portal -> Application Insights -> Failed requests.
Using Serilog ApplicationInsights sink, and the following configuration:
In Startup->Configure
:
var appInsightsConfig = app.ApplicationServices.GetService<TelemetryConfiguration>();
TelemetryProcessorChainBuilder builder = appInsightsConfig.TelemetryProcessorChainBuilder;
// some custom telemetry processor for Application Insights that filters out synthetic traffic (e.g traffic that comes from Azure to keep the server awake).
builder.UseAdaptiveSampling(excludedTypes: "Exception");
builder.Build();
In Startup->ConfigureServices
:
services.AddApplicationInsightsTelemetry(o =>
{
o.EnableAdaptiveSampling = false; // Disable adaptive sampling here, so we can configure it in the Configure method
});
In Program->Main
a Serilog sink is configured:
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(Configuration)
.WriteTo.ApplicationInsights(TelemetryConfiguration.Active, TelemetryConverter.Traces)
.CreateLogger();
Packages:
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.2" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.0.4" />
A valid telemetry key is set in application.json
.
Can you please advise if the above configuration is correct for enabling adaptive sampling, but never sample out api requests which have an uncaught exception?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment