Skip to content

Commit 19c7daf

Browse files
committed
Split config check test for different scenarios
1 parent 5832c73 commit 19c7daf

5 files changed

Lines changed: 93 additions & 45 deletions

tests/ext/distributed_tracing/propagation_behavior_extract_config.phpt

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT: invalid value falls back to continue
3+
--ENV--
4+
DD_TRACE_GENERATE_ROOT_SPAN=0
5+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT=invalid_value
6+
--FILE--
7+
<?php
8+
9+
DDTrace\consume_distributed_tracing_headers([
10+
"x-datadog-trace-id" => 42,
11+
"x-datadog-parent-id" => 10,
12+
]);
13+
14+
$span = DDTrace\start_span();
15+
$root = DDTrace\root_span();
16+
17+
// invalid value falls back to default (continue): inherits upstream trace id
18+
echo "same_as_upstream: " . ($root->traceId === "0000000000000000000000000000002a" ? "yes" : "no") . "\n";
19+
20+
DDTrace\close_span();
21+
?>
22+
--EXPECT--
23+
same_as_upstream: yes
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT: Ignore (mixed case) is accepted
3+
--ENV--
4+
DD_TRACE_GENERATE_ROOT_SPAN=0
5+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT=Ignore
6+
--FILE--
7+
<?php
8+
9+
DDTrace\consume_distributed_tracing_headers([
10+
"x-datadog-trace-id" => 42,
11+
"x-datadog-parent-id" => 10,
12+
]);
13+
14+
$span = DDTrace\start_span();
15+
$root = DDTrace\root_span();
16+
17+
echo "same_as_upstream: " . ($root->traceId === "0000000000000000000000000000002a" ? "yes" : "no") . "\n";
18+
echo "links_count: " . count($root->links) . "\n";
19+
20+
DDTrace\close_span();
21+
?>
22+
--EXPECT--
23+
same_as_upstream: no
24+
links_count: 0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT: CONTINUE (uppercase) is accepted
3+
--ENV--
4+
DD_TRACE_GENERATE_ROOT_SPAN=0
5+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT=CONTINUE
6+
--FILE--
7+
<?php
8+
9+
DDTrace\consume_distributed_tracing_headers([
10+
"x-datadog-trace-id" => 42,
11+
"x-datadog-parent-id" => 10,
12+
]);
13+
14+
$span = DDTrace\start_span();
15+
$root = DDTrace\root_span();
16+
17+
echo "same_as_upstream: " . ($root->traceId === "0000000000000000000000000000002a" ? "yes" : "no") . "\n";
18+
19+
DDTrace\close_span();
20+
?>
21+
--EXPECT--
22+
same_as_upstream: yes
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT: RESTART (uppercase) is accepted
3+
--ENV--
4+
DD_TRACE_GENERATE_ROOT_SPAN=0
5+
DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT=RESTART
6+
--FILE--
7+
<?php
8+
9+
DDTrace\consume_distributed_tracing_headers([
10+
"x-datadog-trace-id" => 42,
11+
"x-datadog-parent-id" => 10,
12+
]);
13+
14+
$span = DDTrace\start_span();
15+
$root = DDTrace\root_span();
16+
17+
echo "same_as_upstream: " . ($root->traceId === "0000000000000000000000000000002a" ? "yes" : "no") . "\n";
18+
echo "links_count: " . count($root->links) . "\n";
19+
20+
DDTrace\close_span();
21+
?>
22+
--EXPECT--
23+
same_as_upstream: no
24+
links_count: 1

0 commit comments

Comments
 (0)