With ApplicationInsights SDK 2.11-beta1 we are deprecating TelemetryConfiguration.Active on .NET core apps, see #1148.
ApplicationInsights exposes TelemetryConfiguration.Active singleton to enable auto-configuration scenarios in the absence of a dependency injection framework.
It is used on ASP.NET Classic apps (in Microsoft.ApplicationInsights.Web SDK). The configuration is read from the ApplicationInsights.config file by auto-collectors when an application starts.
User can access configuration that is used by auto-collectors and is able to customize it.
It is not the case for ASP.NET Core application where Dependency Injection is part of the framework - ApplicationInsights configuration is done and could be accessed and customized through DI container. The details and examples could be found here; https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core
Active singleton creates issues typical for static singletons - lifetime it tight to process, testing is complicated. This is especially problematic in ASP.NET core apps, Azure WebJobs, and generic host apps, where one process may host multiple applications. So there ApplicationInsights SDK configures an instance of TelemetryConfiguration per host. It frequently results in confusion around which instance of configuration to use: one in the DI container or Active.
With ApplicationInsights SDK 2.11-beta1 we are deprecating
TelemetryConfiguration.Activeon .NET core apps, see #1148.ApplicationInsights exposes
TelemetryConfiguration.Activesingleton to enable auto-configuration scenarios in the absence of a dependency injection framework.It is used on ASP.NET Classic apps (in Microsoft.ApplicationInsights.Web SDK). The configuration is read from the ApplicationInsights.config file by auto-collectors when an application starts.
User can access configuration that is used by auto-collectors and is able to customize it.
It is not the case for ASP.NET Core application where Dependency Injection is part of the framework - ApplicationInsights configuration is done and could be accessed and customized through DI container. The details and examples could be found here; https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core
Activesingleton creates issues typical for static singletons - lifetime it tight to process, testing is complicated. This is especially problematic in ASP.NET core apps, Azure WebJobs, and generic host apps, where one process may host multiple applications. So there ApplicationInsights SDK configures an instance ofTelemetryConfigurationper host. It frequently results in confusion around which instance of configuration to use: one in the DI container or Active.If you use ApplicationInsights SDK for ASP.NET Core apps - follow this document for guidance on how to configure AppInsights: https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core
If you use AzureFunctions v2+ or Azure WebJobs v3+ - follow this document: https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring#version-2x-3
If you have other kind of application where you configure
TelemetryConfigurationyourself - do not useTelemetryConfiguration.Activesingleton.You should create configuration instance and may carry it explicitly in your code, leverage DI from Microsoft.Extensions.DependencyInjection or any other available DI framework or even create your own global static variable to store
TelemetryConfigurationinstance you create.