Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Remote Dependency requests don't "always" have the correct ai.operation.id tag (page view race condition) #1862

Closed
MSNev opened this issue Jul 6, 2022 · 1 comment
Assignees
Labels
investigating Investigating the issue p2 production released - NPM SPA support Required to support SPA style apps
Milestone

Comments

@MSNev
Copy link
Collaborator

MSNev commented Jul 6, 2022

When an ajax (XHR/fetch) request occurs it is provided with the "requestId" and "traceparent" headers for distributed tracing downstream based on the current "traceId" of the page (which is the correct behavior) and when the response for the request is received the SDK will cause an event to be sent via the trackInternalDependency function.

However, this call will only occur after BOTH of the following

  • The response is received (even a failed / timed out response)
  • if enableAjaxperfTracking is enabled after the runtime populates the performance event for the request OR the SDK times out waiting for the value (defaults to 3 attempts every 25ms (75ms total)).

Additionally, during the construction of the event (that is passed to the track call) and it getting stored in the internal buffer (waiting to be sent) the event will be populated with a bunch of standard values including the tag ai.operation.id which is the current value at the point of the trackXXXX() call.

Normally, this is not an issue
-- unless a page navigation occurs OR you set / change the traceID for the page (between) the time the ajax was "sent" to the time that it's trackXXX() call is made. In this case the ai.operation.id tag value sent for the request will be that of the "current page" and not the page that triggered the event.

To address this issue fix required (further analysis / investigation required), looks like it would be to

  • Set the ext.trace values on the event before calling traceInternalDependency
  • Update the TelemetryContext code to use getSetValue() instead of setValue() (which always set the value) or add a isNullOrUndefined value check argument to to the setVeluer helper. Otherwise, this code will ALWAYS overwrite any value on the event.
@MSNev MSNev added p2 production SPA support Required to support SPA style apps labels Jul 6, 2022
@MSNev MSNev added this to the 2.8.6 milestone Jul 6, 2022
@MSNev MSNev changed the title [BUG] Remote Dependency requests don't "always" have the correct ai.operation.id tag [BUG] Remote Dependency requests don't "always" have the correct ai.operation.id tag (page view race condition) Jul 6, 2022
@MSNev MSNev self-assigned this Jul 29, 2022
@MSNev MSNev added the investigating Investigating the issue label Jul 29, 2022
MSNev added a commit to MSNev/ApplicationInsights-JS that referenced this issue Jul 30, 2022
MSNev added a commit that referenced this issue Aug 1, 2022
@MSNev MSNev added fixed - waiting release PR Committed and waiting deployment released - NPM waiting - CDN deployment and removed fixed - waiting release PR Committed and waiting deployment labels Aug 1, 2022
@MSNev MSNev closed this as completed Aug 9, 2022
MSNev added a commit to MSNev/ApplicationInsights-JS that referenced this issue Oct 3, 2022
* [BUG] Snippet initialization with IE8/9 fails with minified code (works with un-minified code) microsoft#1852 (microsoft#1854)

* [BUG] CDN Packaging is not exposing the internal tools (CoreUtils / Telemetry / etc) microsoft#1857 (microsoft#1858)

* fix stopTrackEvents (microsoft#1859)

Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>

* Refactor code to provide better tree shaking and minification of generated code microsoft#1076 (microsoft#1811)

- Add Automatic Name replacing / Crunching

* Address Component Governance issues (microsoft#1860)

- Update npm to 8.13.2
- Update rush to 5.75.0

* [Release] Increase version to 2.8.5 (microsoft#1861)

- Updates React Plugin to v3.3.5 (with v2.8.5 as dependency) -- using React 17
- Updates React Native Plugin to 2.5.5 (with v2.8.5 as dependency)
- Updates Chrome Debug Extension to 0.3.5

* Update and add legal compliance notices and license terms (microsoft#1865)

* Remove React-JS and React-Native code from this repo (microsoft#1866)

* [BUG] Remote Dependency requests don't "always" have the correct ai.operation.id tag (page view race condition) microsoft#1862 (microsoft#1869)

* [BUG] Performance improvements when calling newGuid multiple times (like 10,000) microsoft#1870 (microsoft#1871)

* [Release] Increase version to 2.8.6 (microsoft#1872)

* add click plugin url config back (microsoft#1874)

* fix(AISKULight): call getSKUDefaults after it's defined, change this.config references to _self (microsoft#1876)

Closes: microsoft#1875

* Merge master to beta @ 6ba2c0d

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Co-authored-by: Lindsay Evans <linz@linz.id.au>
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
investigating Investigating the issue p2 production released - NPM SPA support Required to support SPA style apps
Projects
None yet
Development

No branches or pull requests

1 participant