From 68d6894601c425f7881e539fb9d253a70b7f9d0b Mon Sep 17 00:00:00 2001 From: Iliar Turdushev Date: Fri, 27 Sep 2024 01:01:37 +0200 Subject: [PATCH] Describes compatibility issue with .NET App Insights (#5444) --- .../README.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md index d4ad24b5e0..b1d43b738a 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/README.md @@ -103,6 +103,26 @@ There's a build time check that verifies if you're using `Grpc.Net.ClientFactory ``` +### 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(); +``` + ## Feedback & Contributing We welcome feedback and contributions in [our GitHub repo](https://github.com/dotnet/extensions).