-
Notifications
You must be signed in to change notification settings - Fork 77
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
Fix context propagation across goroutines #118
Conversation
Blocked by: #82 |
Related to #86 |
@open-telemetry/go-instrumentation-approvers this is ready for review, thanks! 🙏 |
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.
@edeNFed is this ready for another round of review or have you more changes planned? |
@open-telemetry/go-instrumentation-approvers This is ready for another review |
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.
Looks great, thanks @edeNFed 👍🏻
What's changed
get_consistent_key
: This function provides a key that works across any version of Go. This key should be used in the eBPF map created by the instrumentor to record the end timestamp at the end of the probed function.start_tracking_span(void *contextContext, struct span_context *sc)
- This function should be used in order to perform in-process context propagation, meaning passing context between different instrumentations in the same applications (see below test case for example).stop_tracking_span(struct span_context *sc)
- This function marks the passed span context as no more relevant for context propagation. This function should usually be called when recording the end timestamp of a span.get_parent_span_context(void *ctx)
- Use this function in order to get the parent span context if available. This function receives the address ofcontext.Context
object.Modified existing instrumentors to use those functions when reading/writing to eBPF maps and to performing context propagation between instrumentors.
Modified gRPC (client) instrumentation to inject headers by probing
loopyWriter.headerHandler
instead ofhttp2Client createHeaderFields
: In Go >= 1.17, the return value is passed by registers and not by the stack. Currently, eBPF is not able to modify registers' values, only memory. Changing the uprobe to attach toloopyWriter.headerHandler
allow us to add context-propagation headers even on Go versions above 1.17.Validation
I used the following code as a test case:
Which produces the following trace (after the applied fix)
Tested on Go 1.15 and 1.20, both on arm64 and amd64