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

[Honeycomb] Set active context before async requests #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pkanal
Copy link

@pkanal pkanal commented Sep 25, 2023

Context on missing context

Since Zone.js does not support async / await, the OpenTelemetry active context gets reset after an async / await block is executed. To get the complex_flow_with_two_requests span to be the parent span to both request spans, we'll have to manually set the active context for them to attach to the parent span. For manual spans, you can pass the ctx directly to the span, but since the request spans are being generated by auto-instrumentation, we have to set the context we want to the active context so that the spans generated by the auto-instrumentation pick up the correct context.

Changes

  • Get the active context after complex_flow_with_two_requests has been created
  • Create a context key (need this to set the active context)
  • Wrap both async requests in context.with callback functions with the context set explicitly as complex_flow_with_two_requests

Testing

Tested in Jaeger and now we can see that both request spans are children of the complex_flow_with_two_requests span
Screenshot 2023-09-25 at 3 45 35 PM

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.

1 participant