You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a long-living operation (context), I want to start a new Trace that is linked to the long-living operation. An example can be a bidirectional grpc stream where every received message represents a new operation, or a long living consumer operation in a pub-sub solution where every received message is a new operation.
Right now, I had to do something like this (in a grpc case):
// Since the receiverCtx is long lived do not use it to start the span, just link to it._, span=rec.tracer.Start(context.Background(), spanName, trace.WithLinks(trace.Link{
SpanContext: trace.SpanContextFromContext(receiverCtx),
}))
ctx=trace.ContextWithSpan(receiverCtx, span)
Proposed Solution
// Since the receiverCtx is long lived do not use it to start the span, just link to it.ctx, span=rec.tracer.Start(receiverCtx, spanName, trace.WithParentAsLink(true))
OR:
// Since the receiverCtx is long lived do not use it to start the span, just link to it.ctx, span=rec.tracer.Start(receiverCtx, spanName, trace.WithNoParent(true), trace.WithLinks(trace.Link{
SpanContext: trace.SpanContextFromContext(receiverCtx),
})
The text was updated successfully, but these errors were encountered:
Does the existing trace.WithNewRoot() option enable the second proposed solution? I think trace.WithParentAsLink(true) is nicer/simpler, but perhaps combining WIthNewRoot and a simpler Link initializer might be more flexible.
Problem Statement
In a long-living operation (context), I want to start a new Trace that is linked to the long-living operation. An example can be a bidirectional grpc stream where every received message represents a new operation, or a long living consumer operation in a pub-sub solution where every received message is a new operation.
Right now, I had to do something like this (in a grpc case):
Proposed Solution
OR:
The text was updated successfully, but these errors were encountered: