microsoft / ApplicationInsights-JS

Microsoft Application Insights SDK for JavaScript
MIT License
642 stars 236 forks source link

Correlation information is not being sent #1019

Closed freerangeeggs closed 4 years ago

freerangeeggs commented 4 years ago

I have an angular app calling a backend API, both log telemetry to their own instances of AI. I am attempting to have distributed tracing work across both. I am using AI-web 2.2.0 and AI-dotnet 2.10.0

This is what I see on the Front-end AI: image

This is what I see when looking at AI for the API: image

I expect to have the latter result in both AI instances.

As they are on different domains, I have enableCorsCorrelation set to true.

I can see the Request-Id and Request-Context are correctly being sent to my API, and my API returning Request-Context with an AppId and the API has exposed the Request-Context so the header can be read by xhr.getAllResponseHeaders()

When stepping through the code, I can see dependency.correlationContext is being set to the appId rather than dependency.target being appended with the appId.

When looking at the network traffic, correlationContext is not being sent to AI. I can see that the correlationContext is not being serialized on creation of the dependency envelope.

If I use fiddler to manually adjust the traffic:

I have attempted to use a Telemetry Initializer to adjust the target so it includes the AppId, but it is overwritten before it is posted.

Where I notice that dependency.correlationContext is being set in favor of appending dependency.target, I see that this is a change as part of the vNext folder, should this be part of the current deployment?

markwolff commented 4 years ago

Thanks for the report. It seems this bit was commented out for some reason or another. I'll enable it for the next release

freerangeeggs commented 4 years ago

Awesome, thank you!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.