@@ -48,6 +48,8 @@ abstract class AbstractServlet3Test<CONTEXT> extends AgentTestRunner {
48
48
addServlet(context, " /blocking" , TestServlet3.BlockingAsync )
49
49
addServlet(context, " /dispatch/sync" , TestServlet3.DispatchSync )
50
50
addServlet(context, " /dispatch/async" , TestServlet3.DispatchAsync )
51
+ addServlet(context, " /dispatch/recursive" , TestServlet3.DispatchRecursive )
52
+ addServlet(context, " /recursive" , TestServlet3.DispatchRecursive )
51
53
addServlet(context, " /fake" , TestServlet3.FakeAsync )
52
54
}
53
55
@@ -116,10 +118,10 @@ abstract class AbstractServlet3Test<CONTEXT> extends AgentTestRunner {
116
118
" fake" | " Hello FakeAsync" | false | " FakeAsync" | true
117
119
}
118
120
119
- def " test dispatch #path" () {
121
+ def " test dispatch #path with depth #depth " () {
120
122
setup :
121
123
def requestBuilder = new Request.Builder ()
122
- .url(" http://localhost:$port /$context /dispatch/$path " )
124
+ .url(" http://localhost:$port /$context /dispatch/$path ?depth= $d epth " )
123
125
.get()
124
126
if (distributedTracing) {
125
127
requestBuilder. header(" x-datadog-trace-id" , " 123" )
@@ -130,14 +132,51 @@ abstract class AbstractServlet3Test<CONTEXT> extends AgentTestRunner {
130
132
expect :
131
133
response. body(). string(). trim() == " Hello $origin "
132
134
133
- assertTraces(2 ) {
134
- trace(0 , 1 ) {
135
+ assertTraces(2 + depth) {
136
+ for (int i = 0 ; i < depth; i++ ) {
137
+ trace(i, 1 ) {
138
+ span(0 ) {
139
+ if (i == 0 ) {
140
+ if (distributedTracing) {
141
+ traceId " 123"
142
+ parentId " 456"
143
+ } else {
144
+ parent()
145
+ }
146
+ } else {
147
+ childOf TEST_WRITER [i - 1 ][0 ]
148
+ }
149
+ serviceName context
150
+ operationName " servlet.request"
151
+ resourceName " GET /$context /dispatch/$path "
152
+ spanType DDSpanTypes . WEB_SERVLET
153
+ errored false
154
+ tags {
155
+ " http.url" " http://localhost:$port /$context /dispatch/$path "
156
+ " http.method" " GET"
157
+ " span.kind" " server"
158
+ " component" " java-web-servlet"
159
+ " span.origin.type" { it == " TestServlet3\$ Dispatch$origin " || it == ApplicationFilterChain . name }
160
+ " span.type" DDSpanTypes . WEB_SERVLET
161
+ " http.status_code" 200
162
+ " servlet.context" " /$context "
163
+ " servlet.dispatch" " /dispatch/recursive?depth=${ depth - i - 1} "
164
+ defaultTags(i > 0 ? true : distributedTracing)
165
+ }
166
+ }
167
+ }
168
+ }
169
+ trace(depth, 1 ) {
135
170
span(0 ) {
136
- if (distributedTracing) {
137
- traceId " 123"
138
- parentId " 456"
171
+ if (depth > 0 ) {
172
+ childOf TEST_WRITER [depth - 1 ][0 ]
139
173
} else {
140
- parent()
174
+ if (distributedTracing) {
175
+ traceId " 123"
176
+ parentId " 456"
177
+ } else {
178
+ parent()
179
+ }
141
180
}
142
181
serviceName context
143
182
operationName " servlet.request"
@@ -154,24 +193,26 @@ abstract class AbstractServlet3Test<CONTEXT> extends AgentTestRunner {
154
193
" http.status_code" 200
155
194
" servlet.context" " /$context "
156
195
" servlet.dispatch" " /$path "
157
- defaultTags(distributedTracing)
196
+ defaultTags(depth > 0 ? true : distributedTracing)
158
197
}
159
198
}
160
199
}
161
- trace(1 , 1 ) {
200
+ trace(depth + 1 , 1 ) {
162
201
span(0 ) {
163
202
serviceName context
164
203
operationName " servlet.request"
165
204
resourceName " GET /$context /$path "
166
205
spanType DDSpanTypes . WEB_SERVLET
167
206
errored false
168
- childOf TEST_WRITER [0 ][0 ]
207
+ childOf TEST_WRITER [depth ][0 ]
169
208
tags {
170
209
" http.url" " http://localhost:$port /$context /$path "
171
210
" http.method" " GET"
172
211
" span.kind" " server"
173
212
" component" " java-web-servlet"
174
- " span.origin.type" { it == " TestServlet3\$ $origin " || it == ApplicationFilterChain . name }
213
+ " span.origin.type" {
214
+ it == " TestServlet3\$ $origin " || it == " TestServlet3\$ DispatchRecursive" || it == ApplicationFilterChain . name
215
+ }
175
216
" span.type" DDSpanTypes . WEB_SERVLET
176
217
" http.status_code" 200
177
218
" servlet.context" " /$context "
@@ -182,11 +223,17 @@ abstract class AbstractServlet3Test<CONTEXT> extends AgentTestRunner {
182
223
}
183
224
184
225
where :
185
- path | distributedTracing
186
- " sync" | true
187
- " sync" | false
188
- " async" | true
189
- " async" | false
226
+ path | distributedTracing | depth
227
+ " sync" | true | 0
228
+ " sync" | false | 0
229
+ " async" | true | 0
230
+ " async" | false | 0
231
+ " recursive" | true | 0
232
+ " recursive" | false | 0
233
+ " recursive" | true | 1
234
+ " recursive" | false | 1
235
+ " recursive" | true | 20
236
+ " recursive" | false | 20
190
237
191
238
origin = path. capitalize()
192
239
}
0 commit comments