Skip to content

Commit 815b431

Browse files
committed
fix(integration): PHP 8.4 Closure::__debugInfo() now includes the name, file, and line
1 parent e988b2a commit 815b431

22 files changed

+1904
-10
lines changed

tests/integration/attributes/test_transaction_closure_clm.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class name, and lineno for closures.
1414
if (version_compare(PHP_VERSION, "7.0", "<")) {
1515
die("skip: CLM for PHP 5 not supported\n");
1616
}
17+
if (version_compare(PHP_VERSION, "8.4", ">=")) {
18+
die("skip: newer test for PHP 8.4+\n");
19+
}
1720
*/
1821

1922
/*INI
@@ -94,7 +97,7 @@ class name, and lineno for closures.
9497
},
9598
{},
9699
{
97-
"code.lineno": 151,
100+
"code.lineno": 154,
98101
"code.filepath": "__FILE__",
99102
"code.function": "{closure}"
100103
}
@@ -115,7 +118,7 @@ class name, and lineno for closures.
115118
},
116119
{},
117120
{
118-
"code.lineno": 159,
121+
"code.lineno": 162,
119122
"code.filepath": "__FILE__",
120123
"code.function": "{closure}"
121124
}
@@ -136,7 +139,7 @@ class name, and lineno for closures.
136139
},
137140
{},
138141
{
139-
"code.lineno": 159,
142+
"code.lineno": 162,
140143
"code.filepath": "__FILE__",
141144
"code.function": "{closure}"
142145
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
The agent should send code level metrics (CLM) including function name,
9+
class name, and lineno for closures.
10+
*/
11+
12+
/*SKIPIF
13+
<?php
14+
if (version_compare(PHP_VERSION, "8.4", "<")) {
15+
die("skip: older test for PHP 8.3 and below\n");
16+
}
17+
*/
18+
19+
/*INI
20+
newrelic.distributed_tracing_enabled=1
21+
newrelic.span_events_enabled=1
22+
newrelic.cross_application_tracer.enabled=false
23+
newrelic.code_level_metrics.enabled=true
24+
*/
25+
26+
/*EXPECT_ANALYTICS_EVENTS
27+
[
28+
"?? agent run id",
29+
{
30+
"reservoir_size": 50,
31+
"events_seen": 1
32+
},
33+
[
34+
[
35+
{
36+
"type": "Transaction",
37+
"name": "OtherTransaction/php__FILE__",
38+
"timestamp": "??",
39+
"duration": "??",
40+
"totalTime": "??",
41+
"guid": "??",
42+
"sampled": true,
43+
"priority": "??",
44+
"traceId": "??",
45+
"error": false
46+
},
47+
{
48+
},
49+
{}
50+
]
51+
]
52+
]
53+
*/
54+
55+
/*EXPECT_SPAN_EVENTS
56+
[
57+
"?? agent run id",
58+
{
59+
"reservoir_size": 10000,
60+
"events_seen": 4
61+
},
62+
[
63+
[
64+
{
65+
"traceId": "??",
66+
"duration": "??",
67+
"transactionId": "??",
68+
"name": "OtherTransaction\/php__FILE__",
69+
"guid": "??",
70+
"type": "Span",
71+
"category": "generic",
72+
"priority": "??",
73+
"sampled": true,
74+
"nr.entryPoint": true,
75+
"timestamp": "??",
76+
"transaction.name": "OtherTransaction\/php__FILE__"
77+
},
78+
{},
79+
{}
80+
],
81+
[
82+
{
83+
"category": "generic",
84+
"type": "Span",
85+
"guid": "??",
86+
"traceId": "??",
87+
"transactionId": "??",
88+
"name": "Custom\/{closure:__FILE__:??}",
89+
"timestamp": "??",
90+
"duration": "??",
91+
"priority": "??",
92+
"sampled": true,
93+
"parentId": "??"
94+
},
95+
{},
96+
{
97+
"code.lineno": 151,
98+
"code.filepath": "__FILE__",
99+
"code.function": "{closure:__FILE__:??}"
100+
}
101+
],
102+
[
103+
{
104+
"category": "generic",
105+
"type": "Span",
106+
"guid": "??",
107+
"traceId": "??",
108+
"transactionId": "??",
109+
"name": "Custom\/{closure:__FILE__:??}",
110+
"timestamp": "??",
111+
"duration": "??",
112+
"priority": "??",
113+
"sampled": true,
114+
"parentId": "??"
115+
},
116+
{},
117+
{
118+
"code.lineno": 159,
119+
"code.filepath": "__FILE__",
120+
"code.function": "{closure:__FILE__:??}"
121+
}
122+
],
123+
[
124+
{
125+
"category": "generic",
126+
"type": "Span",
127+
"guid": "??",
128+
"traceId": "??",
129+
"transactionId": "??",
130+
"name": "Custom\/{closure:__FILE__:??}",
131+
"timestamp": "??",
132+
"duration": "??",
133+
"priority": "??",
134+
"sampled": true,
135+
"parentId": "??"
136+
},
137+
{},
138+
{
139+
"code.lineno": 159,
140+
"code.filepath": "__FILE__",
141+
"code.function": "{closure:__FILE__:??}"
142+
}
143+
]
144+
]
145+
]
146+
*/
147+
148+
/*
149+
* Closure type 1
150+
*/
151+
echo preg_replace_callback('~-([a-z])~', function ($match) {
152+
sleep(1);
153+
return strtoupper($match[1]);
154+
}, 'hello-world');
155+
156+
/*
157+
* Closure type 2
158+
*/
159+
$greet = function($name) {
160+
sleep(1);
161+
printf("Hello %s\r\n", $name);
162+
};
163+
164+
$greet('World');
165+
$greet('PHP');
166+

tests/integration/attributes/test_transaction_closure_clm_off.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
if (version_compare(PHP_VERSION, "7.0", "<")) {
1414
die("skip: CLM for PHP 5 not supported\n");
1515
}
16+
if (version_compare(PHP_VERSION, "8.4", ">=")) {
17+
die("skip: newer test for PHP 8.4+\n");
18+
}
1619
*/
1720

1821
/*INI
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
The agent should *not* send code level metrics (CLM) when disabled.
9+
*/
10+
11+
/*SKIPIF
12+
<?php
13+
if (version_compare(PHP_VERSION, "8.4", "<")) {
14+
die("skip: older test for PHP 8.3 and below\n");
15+
}
16+
*/
17+
18+
/*INI
19+
newrelic.distributed_tracing_enabled=1
20+
newrelic.span_events_enabled=1
21+
newrelic.cross_application_tracer.enabled=false
22+
newrelic.code_level_metrics.enabled=false
23+
*/
24+
25+
/*EXPECT_ANALYTICS_EVENTS
26+
[
27+
"?? agent run id",
28+
{
29+
"reservoir_size": 50,
30+
"events_seen": 1
31+
},
32+
[
33+
[
34+
{
35+
"type": "Transaction",
36+
"name": "OtherTransaction/php__FILE__",
37+
"timestamp": "??",
38+
"duration": "??",
39+
"totalTime": "??",
40+
"guid": "??",
41+
"sampled": true,
42+
"priority": "??",
43+
"traceId": "??",
44+
"error": false
45+
},
46+
{
47+
},
48+
{}
49+
]
50+
]
51+
]
52+
*/
53+
54+
/*EXPECT_SPAN_EVENTS
55+
[
56+
"?? agent run id",
57+
{
58+
"reservoir_size": 10000,
59+
"events_seen": 4
60+
},
61+
[
62+
[
63+
{
64+
"traceId": "??",
65+
"duration": "??",
66+
"transactionId": "??",
67+
"name": "OtherTransaction\/php__FILE__",
68+
"guid": "??",
69+
"type": "Span",
70+
"category": "generic",
71+
"priority": "??",
72+
"sampled": true,
73+
"nr.entryPoint": true,
74+
"timestamp": "??",
75+
"transaction.name": "OtherTransaction\/php__FILE__"
76+
},
77+
{},
78+
{}
79+
],
80+
[
81+
{
82+
"category": "generic",
83+
"type": "Span",
84+
"guid": "??",
85+
"traceId": "??",
86+
"transactionId": "??",
87+
"name": "Custom\/{closure:__FILE__:??}",
88+
"timestamp": "??",
89+
"duration": "??",
90+
"priority": "??",
91+
"sampled": true,
92+
"parentId": "??"
93+
},
94+
{},
95+
{}
96+
],
97+
[
98+
{
99+
"category": "generic",
100+
"type": "Span",
101+
"guid": "??",
102+
"traceId": "??",
103+
"transactionId": "??",
104+
"name": "Custom\/{closure:__FILE__:??}",
105+
"timestamp": "??",
106+
"duration": "??",
107+
"priority": "??",
108+
"sampled": true,
109+
"parentId": "??"
110+
},
111+
{},
112+
{}
113+
],
114+
[
115+
{
116+
"category": "generic",
117+
"type": "Span",
118+
"guid": "??",
119+
"traceId": "??",
120+
"transactionId": "??",
121+
"name": "Custom\/{closure:__FILE__:??}",
122+
"timestamp": "??",
123+
"duration": "??",
124+
"priority": "??",
125+
"sampled": true,
126+
"parentId": "??"
127+
},
128+
{},
129+
{}
130+
]
131+
]
132+
]
133+
*/
134+
135+
/*
136+
* Closure type 1
137+
*/
138+
echo preg_replace_callback('~-([a-z])~', function ($match) {
139+
sleep(1);
140+
return strtoupper($match[1]);
141+
}, 'hello-world');
142+
143+
/*
144+
* Closure type 2
145+
*/
146+
$greet = function($name) {
147+
sleep(1);
148+
printf("Hello %s\r\n", $name);
149+
};
150+
151+
$greet('World');
152+
$greet('PHP');
153+

tests/integration/errors/test_uncaught_handled_exception_02.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
if (version_compare(PHP_VERSION, "8.0", "<")) {
2727
die("skip: PHP < 8.0.0 not supported\n");
2828
}
29+
if (version_compare(PHP_VERSION, "8.4", ">=")) {
30+
die("skip: newer test for PHP 8.4+\n");
31+
}
2932
*/
3033

3134

0 commit comments

Comments
 (0)