Open legzo opened 3 years ago
Hi Julien, Thanks for your message! Yes, you are correct we have a race condition with multiple coroutines adding to the same Span stack simultaneously. Your solution looks great! I look forward to your contribution to the repo. Francois
Hi,
I ran into an issue when trying to run parallel tasks on the server. In the project I modified the
getAll
function of the client to call the U.S. Geological Survey API multiple times in parallel.The thing is that the spans are all messed up. At least they don't show up as I expected :
I expected something like that :
So I looked at what is done in the
OpenTracingServer
feature and I thought the "problem" was all async tasks share the sameStack<Span>
, and as theproceed()
is wrapped in thistheadLocalSpanStack
context, all modifications done to theStack
is shared with other coroutines. My knowledge of coroutines is quite limited so I may have misunderstood...What I ended up doing is :
With
tracingContext()
defined as follows :This way, I inherit the enclosing span context, but I don't share it between concurrent tasks. It renders my spans as I expected, but then again, I might be missing something.
How would you do it ? Would you expect the same span layout from my example ?
Thanks. Julien