-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Baggage is found, but empty #27
base: main
Are you sure you want to change the base?
Conversation
propagator struct{} | ||
) | ||
|
||
type Values baggage.Baggage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is our special Context Propagator, pulled verbatim from temporalio/samples-go, except with just this line changed
@@ -20,7 +22,8 @@ func NewClient(lc fx.Lifecycle) (client.Client, error) { | |||
} | |||
|
|||
c, err := client.Dial(client.Options{ | |||
Interceptors: interceptors, | |||
Interceptors: interceptors, | |||
ContextPropagators: []workflow.ContextPropagator{ctxpropagation.NewContextPropagator()}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All Temporal clients use Temporal's OTel interceptor, and a special Context Propagator.
See https://github.com/temporalio/samples-go/blob/v1.3.0/ctxpropagation/starter/main.go#L24
// Optional: Sets ContextPropagators that allows users to control the context information passed through a workflow
// default: nil
ContextPropagators []ContextPropagator
logrus.WithField("otel.baggage.num_members", len(members)).Info("OTel baggage") | ||
//for _, m := range bg.Members() { | ||
// span.SetAttributes(attribute.String(m.Key(), m.Value())) | ||
//} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are in the gRPC server interceptor. The server should be able to find baggage in its context.
}, | ||
// create span, do context propagation | ||
otelgrpc.UnaryClientInterceptor(), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are in the Temporal worker. Before we invoke the next interceptor in the chain, we're going to pull baggage from context using our special PropagateKey
and then re-set it in context.
ctx = context.WithValue(ctx, ctxpropagation.PropagateKey, bg) | ||
|
||
return ctx, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are in the Temporal workflow starter. We create some OTel baggage and inject it in context using our special PropagateKey
.
|
||
func injectBaggage(ctx context.Context, workflowID string) (context.Context, error) { | ||
// Inject the workflow ID as OTel baggage, so it appears on all spans | ||
bgMem, err := baggage.NewMember("foo", "bar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're creating some baggage with one element 😄
// EXTRACT BAGGAGE!! | ||
bg := baggage.FromContext(ctx) | ||
members := bg.Members() | ||
logrus.WithField("otel.baggage.num_members", len(members)).Info("OTel baggage") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're seeing 0 baggage elements 😟
Sources: