@@ -543,9 +543,9 @@ public function testGetSpanContextWithMultipleTraceStates()
543543 '_dd.p.congo ' => 't61rcWkgMzE ' ,
544544 '_dd.p.some_val ' => 'tehehe '
545545 ]);
546- $ this ->assertRegularExpression ('/^dd=t.dm:-0 ;t.congo:t61rcWkgMzE;t.some_val:tehehe$/ ' , (string )$ span ->getContext ()->getTraceState ());
546+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16} ;t.congo:t61rcWkgMzE;t.some_val:tehehe;t.dm:-0 $/ ' , (string )$ span ->getContext ()->getTraceState ());
547547 $ span ->end ();
548- $ this ->assertRegularExpression ('/^dd=t.dm:-0 ;t.congo:t61rcWkgMzE;t.some_val:tehehe$/ ' , (string )$ span ->getContext ()->getTraceState ());
548+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16} ;t.congo:t61rcWkgMzE;t.some_val:tehehe;t.dm:-0 $/ ' , (string )$ span ->getContext ()->getTraceState ());
549549 });
550550
551551 $ span = $ traces [0 ][0 ];
@@ -589,7 +589,7 @@ public function testGetSpanContextWithRemoteParent(int $traceFlags, ?TraceState
589589 $ this ->assertSame ($ remoteContext ->getSpanId (), $ child ->getParentContext ()->getSpanId ());
590590 $ this ->assertFalse ($ childContext ->isRemote ()); // "When creating children from remote spans, their IsRemote flag MUST be set to false."
591591 $ this ->assertEquals (1 , $ childContext ->getTraceFlags ()); // RECORD_AND_SAMPLED ==> 01 (AlwaysOn sampler)
592- $ this ->assertSame ("dd=t.dm:-0 " . ($ traceState ? ", $ traceState " : "" ), (string )$ childContext ->getTraceState ());
592+ $ this ->assertSame ("dd=p: " . $ child -> getContext ()-> getSpanID () . " ; t.dm:-0 " . ($ traceState ? ", $ traceState " : "" ), (string )$ childContext ->getTraceState ());
593593 });
594594
595595 $ span = $ traces [0 ][0 ];
@@ -664,11 +664,11 @@ public function getDescription(): string
664664 )))->getTracer ('OpenTelemetry.TracerTest ' );
665665 $ parent = $ tracer ->spanBuilder ("parent " )->startSpan (); // root sampler will be used
666666 $ scope = $ parent ->activate ();
667- $ this ->assertRegularExpression ('/^dd=t.dm:-0,root=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
667+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16}; t.dm:-0,root=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
668668 $ parent ->setAttributes ([
669669 '_dd.p.some_val ' => 'tehehe '
670670 ]);
671- $ this ->assertRegularExpression ('/^dd=t.dm:-0;t.some_val:tehehe,root=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
671+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16}; t.dm:-0;t.some_val:tehehe,root=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
672672 try {
673673 $ child = $ tracer ->spanBuilder ("child " )->startSpan (); // local parent sampler will be used
674674
@@ -677,8 +677,8 @@ public function getDescription(): string
677677 $ this ->assertSame ($ parent ->getContext ()->getSpanId (), $ child ->getParentContext ()->getSpanId ());
678678 $ this ->assertFalse ($ childContext ->isRemote ()); // "When creating children from remote spans, their IsRemote flag MUST be set to false."
679679 $ this ->assertEquals (1 , $ childContext ->getTraceFlags ()); // RECORD_AND_SAMPLED ==> 01 (AlwaysOn sampler)
680- $ this ->assertRegularExpression ('/^dd=t.dm:-0,localparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ childContext ->getTraceState ());
681- $ this ->assertRegularExpression ('/^dd=t.dm:-0,localparent =yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
680+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16}; t.dm:-0,localparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ childContext ->getTraceState ());
681+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16}; t.dm:-0;t.some_val:tehehe,root =yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
682682
683683 $ grandChild = $ tracer ->spanBuilder ("grandChild " )
684684 ->setParent (Context::getCurrent ()->withContextValue ($ child ))
@@ -690,14 +690,14 @@ public function getDescription(): string
690690 $ this ->assertSame ($ child ->getContext ()->getSpanId (), $ grandChild ->getParentContext ()->getSpanId ());
691691 $ this ->assertFalse ($ grandChildContext ->isRemote ()); // "When creating children from remote spans, their IsRemote flag MUST be set to false."
692692 $ this ->assertEquals (1 , $ grandChildContext ->getTraceFlags ()); // RECORD_AND_SAMPLED ==> 01 (AlwaysOn sampler)
693- $ this ->assertRegularExpression ('/^dd=t.dm:-0,localparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ grandChildContext ->getTraceState ());
693+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16}; t.dm:-0,localparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ grandChildContext ->getTraceState ());
694694
695695 $ grandChildScope ->detach ();
696696 $ grandChild ->end ();
697697
698698 $ child ->end ();
699699 } finally {
700- $ this ->assertRegularExpression ('/^dd=t.dm:-0;t.some_val:tehehe,root=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
700+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16}; t.dm:-0;t.some_val:tehehe,root=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE$/ ' , (string )$ parent ->getContext ()->getTraceState ());
701701 $ scope ->detach ();
702702 $ parent ->end ();
703703 }
@@ -806,22 +806,25 @@ public function getDescription(): string
806806 $ this ->assertSame ($ remoteContext ->getSpanId (), $ child ->getParentContext ()->getSpanId ());
807807 $ this ->assertFalse ($ childContext ->isRemote ()); // "When creating children from remote spans, their IsRemote flag MUST be set to false."
808808 $ this ->assertEquals (1 , $ childContext ->getTraceFlags ()); // RECORD_AND_SAMPLED ==> 01 (AlwaysOn sampler)
809- //$this->assertSame("dd=t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE", (string)$childContext->getTraceState());
809+ //$this->assertSame("dd=p:[0-9a-f]{16}; t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE", (string)$childContext->getTraceState());
810810
811811 $ tracer = self ::getTracer ();
812812 $ grandChild = $ tracer ->spanBuilder ("grandChild " )
813813 ->setParent (Context::getCurrent ()->withContextValue ($ child ))
814814 ->startSpan ();
815- $ this ->assertSame ("dd=t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE " , (string )$ child ->getContext ()->getTraceState ());
815+ $ expected_tracestate = "dd=p: " . $ childContext ->getSpanId () . ";t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE " ;
816+ $ this ->assertSame ($ expected_tracestate , (string )$ child ->getContext ()->getTraceState ());
816817 $ grandChildScope = $ grandChild ->activate ();
817818
818819 $ grandChildContext = $ grandChild ->getContext ();
819820 $ this ->assertSame ($ remoteContext ->getTraceId (), $ grandChildContext ->getTraceId ());
820821 $ this ->assertSame ($ child ->getContext ()->getSpanId (), $ grandChild ->getParentContext ()->getSpanId ());
821822 $ this ->assertFalse ($ grandChildContext ->isRemote ()); // "When creating children from remote spans, their IsRemote flag MUST be set to false."
822823 $ this ->assertEquals (1 , $ grandChildContext ->getTraceFlags ()); // RECORD_AND_SAMPLED ==> 01 (AlwaysOn sampler)
823- $ this ->assertSame ("dd=t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE " , (string )$ child ->getContext ()->getTraceState ());
824- $ this ->assertSame ("dd=t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE " , (string )$ grandChildContext ->getTraceState ());
824+ $ expected_tracestate = "dd=p: " . $ childContext ->getSpanId () . ";t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE " ;
825+ $ this ->assertSame ($ expected_tracestate , (string )$ child ->getContext ()->getTraceState ());
826+ $ expected_tracestate = "dd=p: " . $ grandChildContext ->getSpanId (). ";t.dm:-0,remoteparent=yes,rojo=00f067aa0ba902b7,congo=t61rcWkgMzE " ;
827+ $ this ->assertSame ($ expected_tracestate , (string )$ grandChildContext ->getTraceState ());
825828
826829 $ grandChildScope ->detach ();
827830 $ grandChild ->end ();
@@ -853,7 +856,7 @@ public function testAddItemToTracestate()
853856 '_dd.p.congo ' => 't61rcWkgMzE ' ,
854857 ]);
855858
856- $ this ->assertRegularExpression ('/^dd=t.dm:-0 ;t.congo:t61rcWkgMzE$/ ' , (string )$ span ->getContext ()->getTraceState ());
859+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16} ;t.congo:t61rcWkgMzE;t.dm:-0 $/ ' , (string )$ span ->getContext ()->getTraceState ());
857860
858861 $ traceState = $ span ->getContext ()->getTraceState ()->with ('rojo ' , '00f067aa0ba902b7 ' );
859862 $ context = SpanContext::create (
@@ -867,7 +870,7 @@ public function testAddItemToTracestate()
867870 ->setParent (Context::getCurrent ()->withContextValue (Span::wrap ($ context )))
868871 ->startSpan ();
869872
870- $ this ->assertRegularExpression ('/^dd=t.dm:-0 ;t.congo:t61rcWkgMzE,rojo=00f067aa0ba902b7$/ ' , (string )$ child ->getContext ()->getTraceState ());
873+ $ this ->assertRegularExpression ('/^dd=p:[0-9a-f]{16} ;t.congo:t61rcWkgMzE;t.dm:-0 ,rojo=00f067aa0ba902b7$/ ' , (string )$ child ->getContext ()->getTraceState ());
871874
872875 $ child ->end ();
873876 $ span ->end ();
0 commit comments