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

make SplunkPostDocLoadResourceInstrumentation aware of upstream context (#357) #398

Conversation

sfishel-splunk
Copy link
Contributor

  • add a mutation observer for the document head to capture added <script> and tags,
    maintaining a mapping of the source URLs of those elements to the span context when they were inserted
  • use that mapping to look up parent context when creating spans for those resource fetches
  • add hooks to SplunkContextManager to ensure that mutation observer records can be processed in the same
    context as the logic that initiates the resource load

Description

Problem: when a resourceFetch span is created by the SplunkPostDocLoadResourceInstrumentation, context is not propagated from the code that initiated the resource load.

Solution: use a mutation observer to detect when new elements are added to the document head and record the tracing context at that time, to be used later when resourceFetch spans are created.

Fixes #357

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • Manual testing
  • Added unit tests
  • Added integration tests

Checklist:

  • Changelogs have been updated
  • Unit tests have been added/updated
  • Documentation has been updated
  • Team's resident technical writer tagged on the PR (if there are changes to the documentation)

@sfishel-splunk sfishel-splunk requested review from a team as code owners June 25, 2022 00:14
@sfishel-splunk
Copy link
Contributor Author

@t2t2 / @mhennoch sorry about this, i made a mess of #364 trying to sign the commits and it was easier to just create a new PR

@t2t2 i'm not sure why there are commits from you in this branch that aren't in main, were you just trying to fix my test failures?

@sfishel-splunk
Copy link
Contributor Author

hmm looks like i still didn't get the signing right, will take another look Monday

@sfishel-splunk sfishel-splunk force-pushed the sfishel/context-aware-post-load-resource-instrumentation branch from 2aa6b30 to 1d8fe35 Compare June 26, 2022 23:18
@sfishel-splunk sfishel-splunk force-pushed the sfishel/context-aware-post-load-resource-instrumentation branch 3 times, most recently from bfaeadd to 3ffb624 Compare July 8, 2022 21:07
…xt (signalfx#357)

* add a mutation observer for the document head to capture added <script> and <img> tags,
  maintaining a mapping of the source URLs of those elements to the span context when they were inserted
* use that mapping to look up parent context when creating spans for those resource fetches
* add hooks to SplunkContextManager to ensure that mutation observer records can be processed in the same
  context as the logic that initiates the resource load
@sfishel-splunk sfishel-splunk force-pushed the sfishel/context-aware-post-load-resource-instrumentation branch from 3ffb624 to 4307c2a Compare July 8, 2022 21:08
@t2t2 t2t2 merged commit dbce30a into signalfx:main Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: trace parent for post-document-load resource fetch spans
3 participants