Baggage is found, but empty - #27
Conversation
| propagator struct{} | ||
| ) | ||
|
|
||
| type Values baggage.Baggage |
There was a problem hiding this comment.
This is our special Context Propagator, pulled verbatim from temporalio/samples-go, except with just this line changed
| c, err := client.Dial(client.Options{ | ||
| Interceptors: interceptors, | ||
| Interceptors: interceptors, | ||
| ContextPropagators: []workflow.ContextPropagator{ctxpropagation.NewContextPropagator()}, |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
We're seeing 0 baggage elements 馃槦
Sources: