@@ -154,6 +154,52 @@ public void testChildOfWithSingleSpanTypeAndExtractedContext() {
154154 serverSpan .context ().getSpanId ().toString ());
155155 }
156156
157+ @ Test
158+ public void testChildOfSingleSpanTypeWithExtractedContextDoesNotPropagateExtractedContext () {
159+ //create a client span
160+ final Tracer clientTracer = new Tracer .Builder (new NoopMetricsRegistry (),
161+ "ClientService" ,
162+ dispatcher ).build ();
163+ final Span clientSpan = clientTracer .buildSpan ("Api_call" )
164+ .withTag (Tags .SPAN_KIND .getKey (), Tags .SPAN_KIND_CLIENT )
165+ .start ();
166+ final MapBackedTextMap wireData = new MapBackedTextMap ();
167+ clientTracer .inject (clientSpan .context (), Format .Builtin .TEXT_MAP , wireData );
168+
169+ //create a server
170+ final Tracer serverTracer = new Tracer .Builder (new NoopMetricsRegistry (),
171+ "ServerService" ,
172+ dispatcher ).build ();
173+ final SpanContext wireContext = serverTracer .extract (Format .Builtin .TEXT_MAP , wireData );
174+ final Span serverSpan = serverTracer .buildSpan ("Api" )
175+ .asChildOf (wireContext )
176+ .start ();
177+
178+ //make sure client and server have the same span-ids for single span type
179+ Assert .assertEquals ("trace-ids are not matching" ,
180+ clientSpan .context ().getTraceId ().toString (),
181+ serverSpan .context ().getTraceId ().toString ());
182+ Assert .assertEquals ("server - client span-ids do not match" ,
183+ clientSpan .context ().getSpanId ().toString (),
184+ serverSpan .context ().getSpanId ().toString ());
185+
186+ //not create another child of server span
187+ final Span childOfServerSpan = serverTracer .buildSpan ("child_operation" )
188+ .asChildOf (serverSpan )
189+ .start ();
190+
191+ //make sure server span and child span have the same trace-ids but different span-ids
192+ Assert .assertEquals ("trace-ids are not matching" ,
193+ serverSpan .context ().getTraceId ().toString (),
194+ childOfServerSpan .context ().getTraceId ().toString ());
195+ Assert .assertNotEquals ("server - childOfServerSpan span-ids match - they should not" ,
196+ serverSpan .context ().getSpanId ().toString (),
197+ childOfServerSpan .context ().getSpanId ().toString ());
198+ Assert .assertEquals ("server's span id - childOfServerSpan's parent id do not match" ,
199+ serverSpan .context ().getSpanId ().toString (),
200+ childOfServerSpan .context ().getParentId ().toString ());
201+ }
202+
157203 @ Test
158204 public void testWithTags () {
159205 Span child = tracer .buildSpan ("child" )
0 commit comments