-
Notifications
You must be signed in to change notification settings - Fork 344
Can we define a shared thread-local storage format for Spans? #24
Comments
Some prior art & discussions: DistributedTracing/continuation-local-storage-jvm#1 |
@bensigelman What you posted looks good, but I recall Google didn't promote the use of wrapped Runnable objects as much as it promoted the use of a new threads for each span, so there was effectively not a stack. The RPC client never had to swap the span because it blocked, and the server never had to swap the span because it created or re-used a thread. e.g.,
|
We ended up creating a Span factory that provides static methods to create/destroy spans that set/remove the span from thread local. The factory also allows us to get the span in context on the corresponding thread (similar to TraceContext.getCurrentSpan()). Have not considered cross thread communication as of yet. |
@toaler can you point to or paste some code examples? From your description of the "factory" it seems it had a much richer API than needed purely for propagating span via TLS. We wouldn't want to replicate OT API for spans in another class. |
What do you think of the following approach?
https://github.com/talsma-ict/context-propagation I would be willing to provide an implementation in 'contrib' that uses this construct to manage spans with implicit context, using delegation to existing Tracer implementations.. |
fyi, larger discussion here: opentracing/specification#23 |
also see #115... |
(Closed by #115) |
While explicit context propagation is in many cases the ideal solution, it's not always practical and often requires that people change their code significantly. A thread-local storage (TLS) of the "current span" is widely used approach in various Java tracers. Rather than leaving this issue up for implementations, it would be useful, imo, to define a common mechanism directly in OpenTracing, and increase interoperability between different instrumentations. Specifically, we'd need to define at least two APIs:
Runnable
/Callable
/ etc. for carrying the "current span" over thread boundariesFor (1), the two possible approaches are:
Some prior discussions on Gitter:
Calling code would look approximately like this:
PS: @jmacd thoughts/recollections about the above? It's not precisely what I remember from Java dapper, though maybe that’s not a bad thing. :)
The text was updated successfully, but these errors were encountered: