You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
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?
The text was updated successfully, but these errors were encountered:
This looks like Serilog is configured with TC.Active, but sample Processor is done on the TC retrieved from DI. They are different, hence Serilog logs wont respect.
Either use TC from DI always (recommended approach), or use TC.Active always.
Thank you. It does help. I have a better understanding of the issue now.
However, I am not sure which is the correct approach of using Serilog with ApplicationInsights configured through dependency injection, while also being able to have early logging when application starts.
I have found 2 posts which seem to be related with this problem (configuring Serilog without using TelemetryConfiguration.Active, without losing early logging)
I will follow them to see which is the recommended approach (I haven't had time to try any of the proposed workarounds yet).
Currently they have status Open without a definitive solution.
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
:In
Startup->ConfigureServices
:In
Program->Main
a Serilog sink is configured:Packages:
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?
The text was updated successfully, but these errors were encountered: