Skip to content

Commit 25a2df3

Browse files
committed
test add_custom_tracer with strange input
1 parent 3cc2311 commit 25a2df3

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
Test that adding custom tracers with strange names does not blow up.
9+
*/
10+
11+
/*INI
12+
newrelic.code_level_metrics.enabled = true
13+
*/
14+
15+
/*EXPECT
16+
zip
17+
zap
18+
*/
19+
20+
/*EXPECT_METRICS_EXIST
21+
Custom/MY_function, 1
22+
Custom/MY_class::MY_method, 1
23+
Supportability/api/add_custom_tracer, 4
24+
*/
25+
26+
/*EXPECT_SPAN_EVENTS_LIKE
27+
[
28+
[
29+
{
30+
"category": "generic",
31+
"type": "Span",
32+
"guid": "??",
33+
"traceId": "??",
34+
"transactionId": "??",
35+
"name": "Custom\/MY_function",
36+
"timestamp": "??",
37+
"duration": "??",
38+
"priority": "??",
39+
"sampled": true,
40+
"parentId": "??"
41+
},
42+
{},
43+
{
44+
"code.lineno": "??",
45+
"code.filepath": "__FILE__",
46+
"code.function": "MY_function"
47+
}
48+
],
49+
[
50+
{
51+
"category": "generic",
52+
"type": "Span",
53+
"guid": "??",
54+
"traceId": "??",
55+
"transactionId": "??",
56+
"name": "Custom\/MY_class::MY_method",
57+
"timestamp": "??",
58+
"duration": "??",
59+
"priority": "??",
60+
"sampled": true,
61+
"parentId": "??"
62+
},
63+
{},
64+
{
65+
"code.lineno": "??",
66+
"code.namespace": "MY_class",
67+
"code.filepath": "__FILE__",
68+
"code.function": "MY_method"
69+
}
70+
]
71+
]
72+
*/
73+
74+
/*EXPECT_TRACED_ERRORS null*/
75+
76+
function MY_function($x) {
77+
echo $x;
78+
}
79+
80+
class MY_class {
81+
public static function MY_method($x) {
82+
echo $x;
83+
}
84+
}
85+
86+
/*
87+
* Note that capitalization has been changed to test case insensitive lookup.
88+
*
89+
* Note that the metrics contain the capitalization of the actual code, not
90+
* the parameters we are given.
91+
*/
92+
newrelic_add_custom_tracer("my_FUNCTION");
93+
newrelic_add_custom_tracer("my_CLASS::my_METHOD");
94+
newrelic_add_custom_tracer("$)O#()@::@)@)@@");
95+
newrelic_add_custom_tracer("a::b::c");
96+
97+
MY_function("zip\n");
98+
MY_class::MY_method("zap\n");

0 commit comments

Comments
 (0)