marcinbudny / applicationinsights-owinextensions

MIT License
48 stars 15 forks source link

ParentId is not set #13

Closed ursenzler closed 7 years ago

ursenzler commented 7 years ago

I found out that when I send Error data to ApplicationInsights, the telemetry data misses the ParentId. The result is that the error is not correctly correlated with the root operation. No exception data is provided when looking at a failed request (just "Learn how to track exceptions for failed requests").

Also see http://stackoverflow.com/questions/42858598/exceptions-are-not-shown-in-request-details-but-under-server-exceptions-in-appli

Unfortunately, I have no clue what changes are needed to get the parent Id so that it could be set inside OperationIdTelemetryInitializer

marcinbudny commented 7 years ago

I'll investigate the problem later this week. In the meantime, could you please provide me with a simple repro project - so that I know exactly what the problem is?

marcinbudny commented 7 years ago

Were you able to create a repro project for this?

ursenzler commented 7 years ago

Unfortunately not. I need the help of a colleague because my OWIN knowledge is limited. And I didn't find time with him yet.

ursenzler commented 7 years ago

I created a simple repro project at https://github.com/ursenzler/AspNetOwinApplicationInsightsTest

A single controller with a single method throwing an exception. Exception is sent to Appinsights in a Filter (see Startup.cs).

marcinbudny commented 7 years ago

Remove following line from your ApplicationInsights.config:

<Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web" />

This initializer has functionality, that is overlapping with Application Insights OWIN extensions. In contrast to OWIN extensions, it does utilize the ParentId property. As a result of combining those two, ParentId has different value than OperationId and RequestId. This is why the exception is not linked to the request.

Also a hint: you can still view exceptions, that are thrown within a request by selecting the All available telemetry for this operation option on the request in the portal.

ursenzler commented 7 years ago

Thank you very much. That solved the problem.

Maybe you should add OperationCorrelationTelemetryInitializer to the list of things to remove in the readme.md. It was there after installing AppInsights within VS2017.

marcinbudny commented 7 years ago

Good idea, will do that. The docs were created before AI tools started adding this initializer.