-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Description
After upgrading Serilog.Sinks.ApplicationInsights to v4.0.0 and implementing the corresponding changes, I noticed a great increase in thread count in my azure durable function that caused thread starvation. This behavior did not happen in the the v3.1.0.
Reproduction
The only noticeable code change that maybe can be the source for this issue is changing the setup for the application insights from instrumentationKey to connectionString:
// In v3.1.0
ITelemetryConverter telemetryConverter = new CustomTraceTelemetryConverter();
string instrumentationKey = hostContext.Configuration[ConfigurationConstants.ApplicationInsightsInstrumentationKey];
Logger logger = new LoggerConfiguration()
.MinimumLevel.Is(logEventMinimumLevel)
.WriteTo.Console(outputTemplate: consoleSinkOutputTemplate)
.WriteTo.ApplicationInsights(instrumentationKey, telemetryConverter, restrictedToMinimumLevel: applicationInsightsMinimumLevel)
.Enrich.FromLogContext()
.Enrich.WithProperty("Environment", environment)
.Enrich.WithProperty("Version", version)
.CreateLogger();
// In v4.0.0
ITelemetryConverter telemetryConverter = new CustomTraceTelemetryConverter();
string connectionString = hostContext.Configuration[ConfigurationConstants.ApplicationInsightsConnectionString];
Logger logger = new LoggerConfiguration()
.MinimumLevel.Is(logEventMinimumLevel)
.WriteTo.Console(outputTemplate: consoleSinkOutputTemplate)
.WriteTo.ApplicationInsights(connectionString, telemetryConverter, restrictedToMinimumLevel: applicationInsightsMinimumLevel)
.Enrich.FromLogContext()
.Enrich.WithProperty("Environment", environment)
.Enrich.WithProperty("Version", version)
.CreateLogger();
// This is executed in the Startup.cs of the azure durable function
I also tested the function with both nuget package versions and only changing that part of the code and the results were the following:
Thread count during execution with v3.1.0:
Thread count during execution with v4.0.0:
Expected behavior
The expected beahvior should be the graph shown previously for the thread count while executing with the v3.1.0
Relevant package, tooling and runtime versions
Serilog.Sinks.ApplicationInsights 4.0.0 / 3.1.0
Serilog 2.12.0
Serilog.Extensions.Logging 3.1.0
Serilog.Sinks.Console 4.0.1
Microsoft.Azure.Functions.Extensions 1.1.0
Microsoft.NET.Sdk.Functions 4.1.3
Microsoft.Azure.WebJobs.Extensions.DurableTask 2.8.1
Microsoft.ApplicationInsights.WorkerService Version 2.21.0
.NET 6