@@ -9,7 +9,7 @@ class TraceConfigTest extends AgentTestRunner {
9
9
@Override
10
10
void configurePreAgent () {
11
11
super . configurePreAgent()
12
- injectSysConfig(" dd.trace.methods" , " package.ClassName[method1,method2];${ ConfigTracedCallable.name} [call]" )
12
+ injectSysConfig(" dd.trace.methods" , " package.ClassName[method1,method2];${ ConfigTracedCallable.name} [call]; ${ ConfigTracedCallable2.name } [*]; ${ Animal.name } [animalSound]; ${ DictionaryElement.name } [*]; ${ Floor.name } [setNumber]; ${ Mammal.name } [*] " )
13
13
}
14
14
15
15
class ConfigTracedCallable implements Callable<String > {
@@ -19,18 +19,207 @@ class TraceConfigTest extends AgentTestRunner {
19
19
}
20
20
}
21
21
22
+ class ConfigTracedCallable2 implements Callable<String > {
23
+ int g
24
+
25
+ ConfigTracedCallable2 (){
26
+ g = 4
27
+ }
28
+ @Override
29
+ String call () throws Exception {
30
+ return call_helper()
31
+ }
32
+
33
+ String call_helper () throws Exception {
34
+ return " Hello2!"
35
+ }
36
+
37
+ String getValue () {
38
+ return " hello"
39
+ }
40
+ void setValue (int value ) {
41
+ g = value
42
+ }
43
+ }
44
+
45
+ interface Mammal {
46
+ void name (String newName )
47
+ void height (int newHeight )
48
+ }
49
+
50
+ interface Floor {
51
+ void setNumber ()
52
+ }
53
+
54
+ class Fifth implements Floor {
55
+ int floorNumber
56
+
57
+ void setNumber () {
58
+ floorNumber = 5
59
+ }
60
+ }
61
+
62
+ class Human implements Mammal {
63
+ String name
64
+ String height
65
+
66
+ void name (String newName ){
67
+ name = newName
68
+ }
69
+ void height (int newHeight ){
70
+ height = newHeight
71
+ }
72
+ }
73
+
74
+
75
+ abstract class Animal {
76
+ abstract void animalSound ()
77
+ void sleep () {
78
+ System . out. println (" Zzz" )
79
+ }
80
+ }
81
+
82
+ abstract class DictionaryElement {
83
+ abstract void produceDefinition ()
84
+ }
85
+
86
+ class Sophisticated extends DictionaryElement {
87
+ void produceDefinition () {
88
+ System . out. println (" of such excellence, grandeur, or beauty as to inspire great admiration or awe." )
89
+ }
90
+ }
91
+ class Pig extends Animal {
92
+ void animalSound () {
93
+ System . out. println (" The pig says: wee wee" )
94
+ }
95
+ }
96
+
22
97
def " test configuration based trace" () {
23
- expect :
98
+ when :
24
99
new ConfigTracedCallable (). call() == " Hello!"
100
+ new Pig (). animalSound()
101
+ then :
102
+ assertTraces(2 ) {
103
+ trace(1 ) {
104
+ span {
105
+ resourceName " ConfigTracedCallable.call"
106
+ operationName " trace.annotation"
107
+ tags {
108
+ " $Tags . COMPONENT " " trace"
109
+ defaultTags()
110
+ }
111
+ }
112
+ }
113
+ trace(1 ) {
114
+ span {
115
+ resourceName " Pig.animalSound"
116
+ operationName " trace.annotation"
117
+ tags {
118
+ " $Tags . COMPONENT " " trace"
119
+ defaultTags()
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
25
125
126
+ def " test wildcard configuration" () {
26
127
when :
27
- TEST_WRITER . waitForTraces(1 )
128
+ ConfigTracedCallable2 object = new ConfigTracedCallable2 ()
129
+ object. call()
130
+ object. hashCode()
131
+ object == new ConfigTracedCallable2 ()
132
+ object. toString()
133
+ object. finalize()
134
+ object. getValue()
135
+ object. setValue(5 )
136
+ new Sophisticated (). produceDefinition()
137
+
28
138
29
139
then :
30
- assertTraces(1 ) {
140
+ assertTraces(2 ) {
141
+ trace(2 ) {
142
+ span {
143
+ resourceName " ConfigTracedCallable2.call"
144
+ operationName " trace.annotation"
145
+ tags {
146
+ " $Tags . COMPONENT " " trace"
147
+ defaultTags()
148
+ }
149
+ }
150
+ span {
151
+ resourceName " ConfigTracedCallable2.call_helper"
152
+ operationName " trace.annotation"
153
+ tags {
154
+ " $Tags . COMPONENT " " trace"
155
+ defaultTags()
156
+ }
157
+ }
158
+ }
31
159
trace(1 ) {
32
160
span {
33
- resourceName " ConfigTracedCallable.call"
161
+ resourceName " Sophisticated.produceDefinition"
162
+ operationName " trace.annotation"
163
+ tags {
164
+ " $Tags . COMPONENT " " trace"
165
+ defaultTags()
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ def " test wildcard configuration with class implementing interface" () {
173
+
174
+ when :
175
+ Human charlie = new Human ()
176
+ charlie. name(" Charlie" )
177
+ charlie. height(4 )
178
+
179
+ then :
180
+ assertTraces(2 ) {
181
+ trace(1 ) {
182
+ span {
183
+ resourceName " Human.name"
184
+ operationName " trace.annotation"
185
+ tags {
186
+ " $Tags . COMPONENT " " trace"
187
+ defaultTags()
188
+ }
189
+ }
190
+ }
191
+ trace(1 ) {
192
+ span {
193
+ resourceName " Human.height"
194
+ operationName " trace.annotation"
195
+ tags {
196
+ " $Tags . COMPONENT " " trace"
197
+ defaultTags()
198
+ }
199
+ }
200
+ }
201
+ }
202
+ }
203
+ def " test wildcard configuration based on class extending abstract class" () {
204
+
205
+ when :
206
+ new Pig (). animalSound()
207
+ new Fifth (). setNumber()
208
+ then :
209
+ assertTraces(2 ) {
210
+ trace(1 ) {
211
+ span {
212
+ resourceName " Pig.animalSound"
213
+ operationName " trace.annotation"
214
+ tags {
215
+ " $Tags . COMPONENT " " trace"
216
+ defaultTags()
217
+ }
218
+ }
219
+ }
220
+ trace(1 ) {
221
+ span {
222
+ resourceName " Fifth.setNumber"
34
223
operationName " trace.annotation"
35
224
tags {
36
225
" $Tags . COMPONENT " " trace"
@@ -64,5 +253,9 @@ class TraceConfigTest extends AgentTestRunner {
64
253
" ClassName[method1 , method2]" | [" ClassName" : [" method1" , " method2" ]. toSet()]
65
254
" Class\$ 1[method1 ] ; Class\$ 2[ method2];" | [" Class\$ 1" : [" method1" ]. toSet(), " Class\$ 2" : [" method2" ]. toSet()]
66
255
" Duplicate[method1] ; Duplicate[method2] ;Duplicate[method3];" | [" Duplicate" : [" method3" ]. toSet()]
256
+ " ClassName[*]" | [" ClassName" : [" *" ]. toSet()]
257
+ " ClassName[*,asdfg]" | [:]
258
+ " ClassName[asdfg,*]" | [:]
259
+ " Class[*] ; Class\$ 2[ method2];" | [" Class" : [" *" ]. toSet(), " Class\$ 2" : [" method2" ]. toSet()]
67
260
}
68
261
}
0 commit comments