Instrumenting async operations in Go #2747
-
Please let me know if I should be asking this in another project/forum. We came across a situation where a single request to an M3 endpoint resulted in two traces being created, when we expected a single trace. An example of traces resulting from a request to the I suspect the broken trace is caused by trace context being lost due to a the creation of a new Context within an async operation on this line of code: https://github.com/m3db/m3/blob/master/src/dbnode/client/host_queue.go#L879 I'm unfamiliar with instrumenting async operations and my questions are:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Async is typically a problem in other languages when using a facility like obtaining the "current span". In Go, the context is explicitly passed down, so, async operations should just work. In your specific case, the context is not being propagated, so, being async isn't really relevant to the situation. Can you somehow add context values to this Thrift context? Or start the Thrift context based on your existing context? |
Beta Was this translation helpful? Give feedback.
-
Thanks @jpkrohling @yurishkuro 🙏 Yes, I recall seeing After looking a little deeper into the code, the async is implemented as an internal queue of "operations", and I think these operations' structs will need to be modified to store the original ctx prior to enqueuing, then upon dequing these "operations", use |
Beta Was this translation helpful? Give feedback.
Async is typically a problem in other languages when using a facility like obtaining the "current span". In Go, the context is explicitly passed down, so, async operations should just work. In your specific case, the context is not being propagated, so, being async isn't really relevant to the situation. Can you somehow add context values to this Thrift context? Or start the Thrift context based on your existing context?