-
Notifications
You must be signed in to change notification settings - Fork 99
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
Propagate OpenTelemetry context in tasks #152
Propagate OpenTelemetry context in tasks #152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rewritten thanks so much for the PR, this approach looks spot on! I'm not entirely sure why we're getting warnings, let me pull this down and see if I can sort it out.
It says
That is weird, but I haven't tested it with OTP 25 because absinthe's own tests fail with that version. I'll run tests under OTP 25. --- edit Tests were fine, but dialyzer does not take into account dependencies that are not connected to a runtime app by default. |
Update 2: It was only about adding |
@benwilson512 the type issues are solved. Do you think it can be merged? |
This looks great, thanks! |
When using OpenTelemetry to create trace spans, the context is not automatically propagated to child tasks. This results in spans that have no correlation with their parent, which makes it worthless to trace.
One could wrap everything by hand (for instance, saving the original OTel context in a field of a source, and attaching to it in its
run/1
protocol implementation) but it is repetitive and error-prone.This change automatically attaches the context to every spawned task, so it is already available for creating spans with
or to open and close spans in
:telemetry
handlers (which are run in the child processes)See also the following PR that adds the same support to
absinthe
.