@@ -116,3 +116,34 @@ func TestTracingContextPropagatorWorkflowContextNoSpan(t *testing.T) {
116116 returnCtx , err = ctxProp .ExtractToWorkflow (returnCtx , NewHeaderReader (header ))
117117 assert .NoError (t , err )
118118}
119+
120+ func TestConsistentInjectionExtraction (t * testing.T ) {
121+ t .Parallel ()
122+ tracer , closer , err := jaeger_config.Configuration {ServiceName : "test-service" }.NewTracer ()
123+ require .NoError (t , err )
124+ defer closer .Close ()
125+ ctxProp := NewTracingContextPropagator (zap .NewNop (), tracer )
126+
127+ span := tracer .StartSpan ("test-operation" )
128+ // base64 encoded string '{}'
129+ var baggageVal = "e30="
130+ span .SetBaggageItem ("request-tenancy" , baggageVal )
131+ assert .NotNil (t , span .Context ())
132+ ctx := contextWithSpan (Background (), span .Context ())
133+ header := & shared.Header {
134+ Fields : map [string ][]byte {},
135+ }
136+ err = ctxProp .InjectFromWorkflow (ctx , NewHeaderWriter (header ))
137+ require .NoError (t , err )
138+
139+ extractedCtx , err := ctxProp .ExtractToWorkflow (Background (), NewHeaderReader (header ))
140+ require .NoError (t , err )
141+
142+ extractedSpanContext := spanFromContext (extractedCtx )
143+ extractedSpanContext .ForeachBaggageItem (func (k , v string ) bool {
144+ if k == "request-tenancy" {
145+ assert .Equal (t , v , baggageVal )
146+ }
147+ return false
148+ })
149+ }
0 commit comments