Skip to content

Commit f08df32

Browse files
committed
test(otel): derive expected traceparent flags from the span context
1 parent f25832e commit f08df32

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎tests/Otel/TracingTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function test_inject_traceparent_round_trips_an_active_span_context(): vo
180180

181181
self::assertArrayHasKey('traceparent', $headers);
182182
// The injected traceparent encodes the producer span's trace + span id (W3C format).
183-
$expected = sprintf('00-%s-%s-01', $span->getContext()->getTraceId(), $span->getContext()->getSpanId());
183+
$expected = sprintf('00-%s-%s-%02x', $span->getContext()->getTraceId(), $span->getContext()->getSpanId(), $span->getContext()->getTraceFlags());
184184
self::assertSame($expected, $headers['traceparent']);
185185

186186
// Extracting it back yields a valid remote parent in the same trace.
@@ -269,7 +269,7 @@ public function test_publish_injects_a_traceparent_when_the_transport_carries_he
269269

270270
// The transport received the header path with a W3C traceparent encoding the producer span.
271271
self::assertNotNull($transport->lastHeaders);
272-
$expected = sprintf('00-%s-%s-01', $span->getContext()->getTraceId(), $span->getContext()->getSpanId());
272+
$expected = sprintf('00-%s-%s-%02x', $span->getContext()->getTraceId(), $span->getContext()->getSpanId(), $span->getContext()->getTraceFlags());
273273
self::assertSame($expected, $transport->lastHeaders['traceparent'] ?? null);
274274

275275
// GR-1 / GR-4: the body is the frozen envelope and still stamps trace_id (belt-and-braces).
@@ -551,7 +551,7 @@ public function test_publish_through_the_kafka_transport_propagates_a_traceparen
551551
self::assertNotNull($producer->payload);
552552
self::assertArrayHasKey('traceparent', $producer->headers);
553553
self::assertSame(
554-
sprintf('00-%s-%s-01', $producerSpan->getContext()->getTraceId(), $producerSpan->getContext()->getSpanId()),
554+
sprintf('00-%s-%s-%02x', $producerSpan->getContext()->getTraceId(), $producerSpan->getContext()->getSpanId(), $producerSpan->getContext()->getTraceFlags()),
555555
$producer->headers['traceparent'],
556556
);
557557
self::assertStringNotContainsString('traceparent', $producer->payload);
@@ -578,7 +578,7 @@ public function test_publish_through_the_stomp_transport_propagates_a_traceparen
578578

579579
self::assertSame('orders', $client->destination);
580580
self::assertSame(
581-
sprintf('00-%s-%s-01', $producerSpan->getContext()->getTraceId(), $producerSpan->getContext()->getSpanId()),
581+
sprintf('00-%s-%s-%02x', $producerSpan->getContext()->getTraceId(), $producerSpan->getContext()->getSpanId(), $producerSpan->getContext()->getTraceFlags()),
582582
$client->headers['traceparent'] ?? null,
583583
);
584584
self::assertNotNull($client->body);

0 commit comments

Comments
 (0)