diff --git a/tools/cli/workflow_commands.go b/tools/cli/workflow_commands.go index f07b63d418d..97384d2287f 100644 --- a/tools/cli/workflow_commands.go +++ b/tools/cli/workflow_commands.go @@ -526,12 +526,15 @@ func processHeader(c *cli.Context) (map[string][]byte, error) { headers := mapFromKeysValues(headerKeys, headerValues) // append context headers if exist if span := opentracing.SpanFromContext(c.Context); span != nil && span.Context() != nil { - span.Context().ForeachBaggageItem(func(k, v string) bool { + spanHeaders := make(map[string]string) + if err := span.Tracer().Inject(span.Context(), opentracing.TextMap, opentracing.TextMapCarrier(spanHeaders)); err != nil { + return nil, fmt.Errorf("error in inject span context: %w", err) + } + for k, v := range spanHeaders { if _, exist := headers[k]; !exist { // append only if not exist headers[k] = []byte(v) } - return true - }) + } } return headers, nil } diff --git a/tools/cli/workflow_commands_test.go b/tools/cli/workflow_commands_test.go index d4c59ef49a3..3ac53b2954b 100644 --- a/tools/cli/workflow_commands_test.go +++ b/tools/cli/workflow_commands_test.go @@ -92,7 +92,8 @@ func TestConstructStartWorkflowRequest(t *testing.T) { assert.NotNil(t, request.WorkflowIDReusePolicy) assert.Equal(t, int32(5), *request.DelayStartSeconds) assert.Equal(t, int32(2), *request.JitterStartSeconds) - assert.Equal(t, map[string][]byte{"tracer-test-key": []byte("tracer-test-value")}, request.Header.Fields) + assert.Contains(t, request.Header.Fields, "mockpfx-baggage-tracer-test-key") + assert.Equal(t, []byte("tracer-test-value"), request.Header.Fields["mockpfx-baggage-tracer-test-key"]) firstRunAt, err := time.Parse(time.RFC3339, "2024-07-24T12:00:00Z") assert.NoError(t, err)