Skip to content

Commit a370fc1

Browse files
committed
address feedback
1 parent 52c7683 commit a370fc1

8 files changed

+168
-39
lines changed

tests/integration/distributed_tracing/w3c/test_force_keep_headers_not_sampled.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/*DESCRIPTION
88
Tests that remote_parent_not_sampled = 'always_on' works. Upstream New Relic
99
tracestate is set to be the opposite of the desired result.
10+
Spans should be sampled with a priority of 2.0, and downstream headers should reflect as such.
1011
*/
1112

1213
/*INI
@@ -46,16 +47,30 @@
4647
}
4748
]
4849
]
49-
5050
]
5151
*/
5252

53+
/*EXPECT
54+
ok - insert function succeeded
55+
ok - traceparent sampled flag ok
56+
ok - tracestate sampled flag ok
57+
ok - tracestate priority ok
58+
*/
5359

54-
60+
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
5561

5662
$payload = array(
5763
'traceparent' => "00-74be672b84ddc4e4b28be285632bbc0a-27ddd2d8890283b4-00",
5864
'tracestate' => "123@nr=0-0-1349956-41346604-27ddd2d8890283b4-b28be285632bbc0a-0-1.1273-1569367663277"
5965
);
6066

6167
newrelic_accept_distributed_trace_headers($payload);
68+
69+
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
70+
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
71+
$traceparent = explode('-', $outbound_headers['traceparent']);
72+
$tracestate = explode('-', explode('=', $outbound_headers['tracestate'])[1]);
73+
74+
tap_equal($traceparent[3], '01', 'traceparent sampled flag ok');
75+
tap_equal($tracestate[6], '1', 'tracestate sampled flag ok');
76+
tap_equal($tracestate[7], '2.000000', 'tracestate priority ok');

tests/integration/distributed_tracing/w3c/test_force_keep_headers_not_sampled_non_newrelic.php

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/*DESCRIPTION
88
Tests that remote_parent_not_sampled = 'always_on' works.
9+
Spans should be sampled with a priority of 2.0, and downstream headers should reflect as such.
910
*/
1011

1112
/*INI
@@ -14,11 +15,6 @@
1415
*/
1516

1617
/*HEADERS
17-
X-Request-Start=1368811467146000
18-
Content-Type=text/html
19-
Accept=text/plain
20-
User-Agent=Mozilla/5.0
21-
Referer=http://user:[email protected]/foo?q=bar#fragment
2218
traceparent=00-87b1c9a429205b25e5b687d890d4821f-7d3efb1b173fecfa-00
2319
*/
2420

@@ -27,6 +23,48 @@
2723
CONTENT_LENGTH=348
2824
*/
2925

26+
/*EXPECT_SPAN_EVENTS
27+
[
28+
"?? agent run id",
29+
{
30+
"reservoir_size": 10000,
31+
"events_seen": 1
32+
},
33+
[
34+
[
35+
{
36+
"category": "generic",
37+
"type": "Span",
38+
"guid": "??",
39+
"traceId": "??",
40+
"transactionId": "??",
41+
"name": "WebTransaction\/Uri__FILE__",
42+
"timestamp": "??",
43+
"duration": "??",
44+
"priority": 2.00000,
45+
"sampled": true,
46+
"nr.entryPoint": true,
47+
"parentId": "??",
48+
"transaction.name": "WebTransaction\/Uri__FILE__"
49+
},
50+
{},
51+
{
52+
"parent.transportType": "HTTP",
53+
"response.headers.contentType": "text\/html",
54+
"http.statusCode": 200,
55+
"response.statusCode": 200,
56+
"httpResponseCode": "200",
57+
"request.uri": "__FILE__",
58+
"request.method": "POST",
59+
"request.headers.host": "??",
60+
"request.headers.contentLength": "??"
61+
62+
}
63+
]
64+
]
65+
]
66+
*/
67+
3068
/*EXPECT
3169
ok - insert function succeeded
3270
ok - traceparent sampled flag ok
@@ -36,9 +74,6 @@
3674

3775
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
3876

39-
header('Content-Type: text/html');
40-
header('Content-Length: 41');
41-
4277
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
4378
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
4479
$traceparent = explode('-', $outbound_headers['traceparent']);

tests/integration/distributed_tracing/w3c/test_force_keep_headers_sampled.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/*DESCRIPTION
88
Tests that remote_parent_sampled = 'always_on' works. Upstream New Relic
99
tracestate is set to be the opposite of the desired result.
10+
Spans should be sampled with a priority of 2.0, and downstream headers should reflect as such.
1011
*/
1112

1213
/*INI
@@ -50,12 +51,28 @@
5051
]
5152
*/
5253

54+
/*EXPECT
55+
ok - insert function succeeded
56+
ok - traceparent sampled flag ok
57+
ok - tracestate sampled flag ok
58+
ok - tracestate priority ok
59+
*/
5360

54-
61+
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
5562

5663
$payload = array(
5764
'traceparent' => "00-74be672b84ddc4e4b28be285632bbc0a-27ddd2d8890283b4-01",
5865
'tracestate' => "123@nr=0-0-1349956-41346604-27ddd2d8890283b4-b28be285632bbc0a-0-1.1273-1569367663277"
5966
);
6067

6168
newrelic_accept_distributed_trace_headers($payload);
69+
70+
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
71+
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
72+
$traceparent = explode('-', $outbound_headers['traceparent']);
73+
$tracestate = explode('-', explode('=', $outbound_headers['tracestate'])[1]);
74+
75+
tap_equal($traceparent[3], '01', 'traceparent sampled flag ok');
76+
tap_equal($tracestate[6], '1', 'tracestate sampled flag ok');
77+
tap_equal($tracestate[7], '2.000000', 'tracestate priority ok');
78+

tests/integration/distributed_tracing/w3c/test_force_keep_headers_sampled_non_newrelic.php

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
/*DESCRIPTION
8-
Tests that remote_parent_not_sampled = 'always_on' works.
8+
Tests that remote_parent_sampled = 'always_on' works.
9+
Spans should be sampled with a priority of 2.0, and downstream headers should reflect as such.
910
*/
1011

1112
/*INI
@@ -14,11 +15,6 @@
1415
*/
1516

1617
/*HEADERS
17-
X-Request-Start=1368811467146000
18-
Content-Type=text/html
19-
Accept=text/plain
20-
User-Agent=Mozilla/5.0
21-
Referer=http://user:[email protected]/foo?q=bar#fragment
2218
traceparent=00-87b1c9a429205b25e5b687d890d4821f-7d3efb1b173fecfa-01
2319
*/
2420

@@ -27,6 +23,48 @@
2723
CONTENT_LENGTH=348
2824
*/
2925

26+
/*EXPECT_SPAN_EVENTS
27+
[
28+
"?? agent run id",
29+
{
30+
"reservoir_size": 10000,
31+
"events_seen": 1
32+
},
33+
[
34+
[
35+
{
36+
"category": "generic",
37+
"type": "Span",
38+
"guid": "??",
39+
"traceId": "??",
40+
"transactionId": "??",
41+
"name": "WebTransaction\/Uri__FILE__",
42+
"timestamp": "??",
43+
"duration": "??",
44+
"priority": 2.00000,
45+
"sampled": true,
46+
"nr.entryPoint": true,
47+
"parentId": "??",
48+
"transaction.name": "WebTransaction\/Uri__FILE__"
49+
},
50+
{},
51+
{
52+
"parent.transportType": "HTTP",
53+
"response.headers.contentType": "text\/html",
54+
"http.statusCode": 200,
55+
"response.statusCode": 200,
56+
"httpResponseCode": "200",
57+
"request.uri": "__FILE__",
58+
"request.method": "POST",
59+
"request.headers.host": "??",
60+
"request.headers.contentLength": "??"
61+
62+
}
63+
]
64+
]
65+
]
66+
*/
67+
3068
/*EXPECT
3169
ok - insert function succeeded
3270
ok - traceparent sampled flag ok
@@ -36,9 +74,6 @@
3674

3775
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
3876

39-
header('Content-Type: text/html');
40-
header('Content-Length: 41');
41-
4277
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
4378
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
4479
$traceparent = explode('-', $outbound_headers['traceparent']);

tests/integration/distributed_tracing/w3c/test_force_toss_headers_not_sampled.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/*DESCRIPTION
88
Tests that remote_parent_not_sampled = 'always_off' works. Upstream New Relic
99
tracestate is set to be the opposite of the desired result.
10+
Spans should not be sampled and downstream headers should indicate as such.
1011
*/
1112

1213
/*INI
@@ -17,9 +18,16 @@
1718

1819
/*EXPECT_SPAN_EVENTS
1920
null
20-
*/
21+
*/
2122

23+
/*EXPECT
24+
ok - insert function succeeded
25+
ok - traceparent sampled flag ok
26+
ok - tracestate sampled flag ok
27+
ok - tracestate priority ok
28+
*/
2229

30+
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
2331

2432

2533
$payload = array(
@@ -28,3 +36,12 @@
2836
);
2937

3038
newrelic_accept_distributed_trace_headers($payload);
39+
40+
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
41+
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
42+
$traceparent = explode('-', $outbound_headers['traceparent']);
43+
$tracestate = explode('-', explode('=', $outbound_headers['tracestate'])[1]);
44+
45+
tap_equal($traceparent[3], '00', 'traceparent sampled flag ok');
46+
tap_equal($tracestate[6], '0', 'tracestate sampled flag ok');
47+
tap_not_equal($tracestate[7], '2.000000', 'tracestate priority ok');

tests/integration/distributed_tracing/w3c/test_force_toss_headers_not_sampled_non_newrelic.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/*DESCRIPTION
88
Tests that remote_parent_not_sampled = 'always_off' works.
9+
Spans should not be sampled and downstream headers should indicate as such.
910
*/
1011

1112
/*INI
@@ -14,11 +15,6 @@
1415
*/
1516

1617
/*HEADERS
17-
X-Request-Start=1368811467146000
18-
Content-Type=text/html
19-
Accept=text/plain
20-
User-Agent=Mozilla/5.0
21-
Referer=http://user:[email protected]/foo?q=bar#fragment
2218
traceparent=00-87b1c9a429205b25e5b687d890d4821f-7d3efb1b173fecfa-00
2319
*/
2420

@@ -27,6 +23,10 @@
2723
CONTENT_LENGTH=348
2824
*/
2925

26+
/*EXPECT_SPAN_EVENTS
27+
null
28+
*/
29+
3030
/*EXPECT
3131
ok - insert function succeeded
3232
ok - traceparent sampled flag ok
@@ -36,9 +36,6 @@
3636

3737
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
3838

39-
header('Content-Type: text/html');
40-
header('Content-Length: 41');
41-
4239
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
4340
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
4441
$traceparent = explode('-', $outbound_headers['traceparent']);

tests/integration/distributed_tracing/w3c/test_force_toss_headers_sampled.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/*DESCRIPTION
88
Tests that remote_parent_sampled = 'always_off' works. Upstream New Relic
99
tracestate is set to be the opposite of the desired result.
10+
Spans should not be sampled and downstream headers should indicate as such.
1011
*/
1112

1213
/*INI
@@ -19,12 +20,27 @@
1920
null
2021
*/
2122

23+
/*EXPECT
24+
ok - insert function succeeded
25+
ok - traceparent sampled flag ok
26+
ok - tracestate sampled flag ok
27+
ok - tracestate priority ok
28+
*/
2229

23-
30+
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
2431

2532
$payload = array(
2633
'traceparent' => "00-74be672b84ddc4e4b28be285632bbc0a-27ddd2d8890283b4-01",
2734
'tracestate' => "123@nr=0-0-1349956-41346604-27ddd2d8890283b4-b28be285632bbc0a-1-1.1273-1569367663277"
2835
);
2936

3037
newrelic_accept_distributed_trace_headers($payload);
38+
39+
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
40+
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
41+
$traceparent = explode('-', $outbound_headers['traceparent']);
42+
$tracestate = explode('-', explode('=', $outbound_headers['tracestate'])[1]);
43+
44+
tap_equal($traceparent[3], '00', 'traceparent sampled flag ok');
45+
tap_equal($tracestate[6], '0', 'tracestate sampled flag ok');
46+
tap_not_equal($tracestate[7], '2.000000', 'tracestate priority ok');

tests/integration/distributed_tracing/w3c/test_force_toss_headers_sampled_non_newrelic.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
/*DESCRIPTION
8-
Tests that remote_parent_not_sampled = 'always_off' works.
8+
Tests that remote_parent_sampled = 'always_off' works.
9+
Spans should not be sampled and downstream headers should indicate as such.
910
*/
1011

1112
/*INI
@@ -14,11 +15,6 @@
1415
*/
1516

1617
/*HEADERS
17-
X-Request-Start=1368811467146000
18-
Content-Type=text/html
19-
Accept=text/plain
20-
User-Agent=Mozilla/5.0
21-
Referer=http://user:[email protected]/foo?q=bar#fragment
2218
traceparent=00-87b1c9a429205b25e5b687d890d4821f-7d3efb1b173fecfa-01
2319
*/
2420

@@ -27,6 +23,10 @@
2723
CONTENT_LENGTH=348
2824
*/
2925

26+
/*EXPECT_SPAN_EVENTS
27+
null
28+
*/
29+
3030
/*EXPECT
3131
ok - insert function succeeded
3232
ok - traceparent sampled flag ok
@@ -36,9 +36,6 @@
3636

3737
require_once(realpath (dirname ( __FILE__ )) . '/../../../include/tap.php');
3838

39-
header('Content-Type: text/html');
40-
header('Content-Length: 41');
41-
4239
$outbound_headers = array('Accept-Language' => 'en-US,en;q=0.5');
4340
tap_assert(newrelic_insert_distributed_trace_headers($outbound_headers), 'insert function succeeded');
4441
$traceparent = explode('-', $outbound_headers['traceparent']);

0 commit comments

Comments
 (0)