I want to add a series of asynchronous spans to a single trace so that they all appear in one Tempo timeline. These spans are triggered by a single request, but they are executed asynchronously from a work queue and so don’t have a parent-child relationship with the original request (or between themselves). Furthermore, some of these spans might be remote and running in a different service.
I’m using the Go SDK, so I create an initial span in the code that handles the triggering condition with tracer.Start(ctx)
and then close the span when that handler ends with span.End()
. My question is how to create the asynchronous spans to capture the work that’s done (minutes or perhaps hours) later.
In other words, how can I create a span that belongs to the same trace as a previous span that has already ended?