microsoft / ApplicationInsights-dotnet

ApplicationInsights-dotnet
MIT License
564 stars 287 forks source link

AddApplicationInsightsTelemetry() not working when AddOpenApi() is already called #2915

Open KimihikoSaito opened 1 week ago

KimihikoSaito commented 1 week ago

Describe the bug

Work ApplicationInsightsTelemetry:

services.AddApplicationInsightsTelemetry();
services.AddOpenApi();

DO NOT work ApplicationInsightsTelemetry:

services.AddOpenApi();
services.AddApplicationInsightsTelemetry();

Exception has thrown at inside ApplicationInsightsExtensions.AddCommonTelemetryModules(services);. https://github.com/microsoft/ApplicationInsights-dotnet/blob/e34286b4c8175d7ea47f9227c5b981d661cac470/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs#L335

richardrobberse commented 4 days ago

@KimihikoSaito Thanks for reporting this, saved me a lot of time...