From 80ea70227def05f9a90be134dc077e7029e6bfd3 Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Sat, 28 Sep 2024 15:51:12 +0200 Subject: [PATCH] Adds description of compatibility issue with App Insights (#42728) --- docs/core/resilience/http-resilience.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/core/resilience/http-resilience.md b/docs/core/resilience/http-resilience.md index 834d2e84a414f..8ec42c1d20172 100644 --- a/docs/core/resilience/http-resilience.md +++ b/docs/core/resilience/http-resilience.md @@ -264,3 +264,23 @@ There's a build time check that verifies if you're using `Grpc.Net.ClientFactory true ``` + +### Compatibility with .NET Application Insights + +If you're using .NET Application Insights, then enabling resilience functionality in your application could cause all Application Insights telemetry to be missing. The issue occurs when resilience functionality is registered before Application Insights services. Consider the following sample causing the issue: + +```csharp +// At first, we register resilience functionality. +services.AddHttpClient().AddStandardResilienceHandler(); + +// And then we register Application Insights. As a result, Application Insights doesn't work. +services.AddApplicationInsightsTelemetry(); +``` + +The issue is caused by the following [bug](https://github.com/microsoft/ApplicationInsights-dotnet/issues/2879) in Application Insights and can be fixed by registering Application Insights services before resilience functionality, as shown below: + +```csharp +// We register Application Insights first, and now it will be working correctly. +services.AddApplicationInsightsTelemetry(); +services.AddHttpClient().AddStandardResilienceHandler(); +```