Context Propagation sample not working

We use jwt for authentication which means that workflows and activities need to carry around jwt token of the function that triggers them.

I tried adapting the sample to no avail. then tested the sample and it doesn’t work correctly.

logs below;

|2020-07-13T02:04:02.202+0100|INFO|internal/internal_worker.go:1029|Started Worker|{"Namespace": "default", "TaskQueue": "ctx-propagation", "WorkerID": "82087@moh-abks-mbp.lan@"}|
|---|---|---|---|---|
|2020-07-13T02:04:11.615+0100|DEBUG|internal/internal_event_handlers.go:478|ExecuteActivity|{"Namespace": "default", "TaskQueue": "ctx-propagation", "WorkerID": "82087@moh-abks-mbp.lan@", "WorkflowType": "CtxPropWorkflow", "WorkflowID": "ctx-propagation_fdcb90bf-a3db-4a5f-9262-56aa0e4e9d5b", "RunID": "a675a7cd-6ea9-4a2c-8efd-692290e38c4d", "ActivityID": "5", "ActivityType": "SampleActivity"}|
|2020-07-13T02:04:11.669+0100|INFO|ctxpropagation/workflow.go:29|context propagated to activity|{"Namespace": "default", "TaskQueue": "ctx-propagation", "WorkerID": "82087@moh-abks-mbp.lan@", "WorkflowType": "CtxPropWorkflow", "WorkflowID": "ctx-propagation_fdcb90bf-a3db-4a5f-9262-56aa0e4e9d5b", "RunID": "a675a7cd-6ea9-4a2c-8efd-692290e38c4d", "": ""}|
|2020-07-13T02:04:11.669+0100|INFO|ctxpropagation/workflow.go:30|Workflow completed.|{"Namespace": "default", "TaskQueue": "ctx-propagation", "WorkerID": "82087@moh-abks-mbp.lan@", "WorkflowType": "CtxPropWorkflow", "WorkflowID": "ctx-propagation_fdcb90bf-a3db-4a5f-9262-56aa0e4e9d5b", "RunID": "a675a7cd-6ea9-4a2c-8efd-692290e38c4d"}|
1 Like

Thanks a lot for letting us know. Let me take a look to see if the problem is with the sample of the SDK itself.

1 Like

It looks like the sample forgets to configure the context propagator with the client. Make sure that it is included into client.Options:

c, err := client.NewClient(client.Options{
       HostPort:           client.DefaultHostPort,
       ContextPropagators: []workflow.ContextPropagator{ctxpropagation.NewContextPropagator()},
})

@Cully please track this

It looks like context propagation is broken in the TestSuite. Filed an issue to get this fixed.

Here is the fix for the sample itself: https://github.com/temporalio/go-samples/pull/39

thanks! that sorted it :smiley: