Hello - I have 5 async processing jobs in `GO` all...
# support
s
Hello - I have 5 async processing jobs in
GO
all separate processes not using/passing any context. Lets call them J1..J5 where J1 is the root span and each Job runs sequentially. What is the best way to pass in
parent span ID
to the current job. e.g. J2 parent span id -> J1; J3 -> J2; J4 ->J3; J5 -> J4. I am using GO Otel library and sending them to Signoz but each job is a new trace instead of 1 trace with spans. • Also, can I generate a traceID and set it as well instead of Otel or context to do it for me? I have a Hash that I can use as a TraceID for all the spans.
cc @Srikanth Chekuri as I see your reply to a similar question https://github.com/SigNoz/signoz/issues/3390 (edited)
s
You need to inject the context into the message and extract to set span context when you consume the message.
s
Thanks @Srikanth Chekuri, Any
GO
examples you can share?
s
s
I am surprised this kind of use-case is not easily supported or documented. This is a real use-case for which I was hoping to use Signoz.
I am still blocked and can't find good examples of what you suggested
Should I file a Feature Request for this or I am missing some existing functionality.
s
There is no missing feature. OTEL does it for you most of the time, but you are using queues, so you need to do manual context propagation with OpenTelemetry and there is no documented example of it. Inject the context into carrier
Copy code
import (
	"context"
	"<http://go.opentelemetry.io/otel|go.opentelemetry.io/otel>"
)

carrier := make(map[string][]string)

// Should be replaced with the actual context
ctx := context.Background()

propagator := otel.GetTextMapPropagator()
propagator.Inject(ctx, carrier)
Extract
Copy code
import (
	"context"
	"<http://go.opentelemetry.io/otel|go.opentelemetry.io/otel>"
	"<http://go.opentelemetry.io/otel/propagation|go.opentelemetry.io/otel/propagation>"
)

carrier := make(map[string][]string)

propagator := otel.GetTextMapPropagator()
extractedContext := propagator.Extract(ctx, carrier)