Urs
Urs

Reputation: 228

Exceptions are not shown in Request details but under Server Exceptions in Application Insights

When an exception occurs during execution of a Web.Api controller method in our system, the request is sent to Application Insights as a failure and we send the exception to Application Insights with telemetry.TrackException(actionExecutedContext.Exception);

Behavior:

However, when looking at the details of a failed request (due to a server exception), the Exception part does not show the correlated exception - just the default Learn how to track exceptions for failed requests.

When looking at what is sent to Application Insights inside Visual Studio 2017, I see that the exception and request are correlated (same Operation Id).

But it seams that this gets lost on the way to the detail page.

We use ASP.NET WebApi with OWIN, default Application Insights installation (of nuget packages) and applicationinsights-owinextensions (including the steps described there to setup the OWIN extension).

I think How to link exceptions to requests in Application Insights on Azure? does not apply because the data is shown as correlated in the Visual Studio AppInsights Viewer and when clicking Show telemetry for: this operation inside the details view of the exception inside AppInsights.

Maybe related: Application Insights shows 2 requests for a failure. The first one shows the HTTP Method (e.g. GET) the second one misses the HTTP Method and has a duration that is slightly longer.

Thanks for hints :-)

Upvotes: 1

Views: 967

Answers (2)

Urs
Urs

Reputation: 228

The solution was to remove the Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer from the application insights config file.

This initializer gets in the way of the initializer from applicationinsights-owinextensions nuget package.

Upvotes: 0

Alex Bulankou
Alex Bulankou

Reputation: 2456

As you are using applicationinsights-owinextensions, I checked the code for OperationIdTelemetryInitializer that is used to initialize operation id. I believe the reason you're not seeing telemetry linked correctly on detail blades is that this code is not setting operation.parentId field. To verify whether this is correct you can examine the payload sent to check whether parent.id field is set. The initializer that we are shipping in the officially supported .NET SDK sets operation.id, as well as operation.parentId.

So my recommendation is, once you confirm, that parentId is indeed not set, would be to to either fix the OperationIdTelemetryInitializer used in owin-extensions so it starts setting parentId, or replace it in ApplicationInsights.config with your custom one. The latter approach would make it easy to confirm this theory.

Upvotes: 1

Related Questions