Skip to content

Commit 80ea702

Browse files
Adds description of compatibility issue with App Insights (#42728)
1 parent cdb80ff commit 80ea702

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/core/resilience/http-resilience.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,23 @@ There's a build time check that verifies if you're using `Grpc.Net.ClientFactory
264264
<SuppressCheckGrpcNetClientFactoryVersion>true</SuppressCheckGrpcNetClientFactoryVersion>
265265
</PropertyGroup>
266266
```
267+
268+
### Compatibility with .NET Application Insights
269+
270+
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:
271+
272+
```csharp
273+
// At first, we register resilience functionality.
274+
services.AddHttpClient().AddStandardResilienceHandler();
275+
276+
// And then we register Application Insights. As a result, Application Insights doesn't work.
277+
services.AddApplicationInsightsTelemetry();
278+
```
279+
280+
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:
281+
282+
```csharp
283+
// We register Application Insights first, and now it will be working correctly.
284+
services.AddApplicationInsightsTelemetry();
285+
services.AddHttpClient().AddStandardResilienceHandler();
286+
```

0 commit comments

Comments
 (0)