@@ -21,11 +21,13 @@ describe('express with httpIntegration and not defined maxRequestBodySize', () =
2121 test ( 'captures medium request bodies with default setting (medium)' , async ( ) => {
2222 const runner = createRunner ( )
2323 . expect ( {
24- transaction : {
25- transaction : 'POST /test-body-size' ,
26- request : {
27- data : JSON . stringify ( generatePayload ( MAX_MEDIUM ) ) ,
28- } ,
24+ span : container => {
25+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
26+ name : 'POST /test-body-size' ,
27+ attributes : expect . objectContaining ( {
28+ 'http.request.body.data' : { type : 'string' , value : JSON . stringify ( generatePayload ( MAX_MEDIUM ) ) } ,
29+ } ) ,
30+ } ) ;
2931 } ,
3032 } )
3133 . start ( ) ;
@@ -41,11 +43,13 @@ describe('express with httpIntegration and not defined maxRequestBodySize', () =
4143 test ( 'truncates large request bodies with default setting (medium)' , async ( ) => {
4244 const runner = createRunner ( )
4345 . expect ( {
44- transaction : {
45- transaction : 'POST /test-body-size' ,
46- request : {
47- data : generatePayloadString ( MAX_MEDIUM , true ) ,
48- } ,
46+ span : container => {
47+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
48+ name : 'POST /test-body-size' ,
49+ attributes : expect . objectContaining ( {
50+ 'http.request.body.data' : { type : 'string' , value : generatePayloadString ( MAX_MEDIUM , true ) } ,
51+ } ) ,
52+ } ) ;
4953 } ,
5054 } )
5155 . start ( ) ;
@@ -69,11 +73,13 @@ describe('express with httpIntegration, disabled httpBodies, and explicit maxReq
6973 test ( 'captures request bodies because the explicit size overrides dataCollection.httpBodies' , async ( ) => {
7074 const runner = createRunner ( )
7175 . expect ( {
72- transaction : {
73- transaction : 'POST /test-body-size' ,
74- request : {
75- data : JSON . stringify ( generatePayload ( MAX_SMALL ) ) ,
76- } ,
76+ span : container => {
77+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
78+ name : 'POST /test-body-size' ,
79+ attributes : expect . objectContaining ( {
80+ 'http.request.body.data' : { type : 'string' , value : JSON . stringify ( generatePayload ( MAX_SMALL ) ) } ,
81+ } ) ,
82+ } ) ;
7783 } ,
7884 } )
7985 . start ( ) ;
@@ -97,11 +103,10 @@ describe('express with httpIntegration and maxRequestBodySize: "none"', () => {
97103 test ( 'does not capture any request bodies with "none" setting' , async ( ) => {
98104 const runner = createRunner ( )
99105 . expect ( {
100- transaction : {
101- transaction : 'POST /test-body-size' ,
102- request : expect . not . objectContaining ( {
103- data : expect . any ( String ) ,
104- } ) ,
106+ span : container => {
107+ const serverSpan = container . items . find ( item => item . is_segment ) ;
108+ expect ( serverSpan ?. name ) . toBe ( 'POST /test-body-size' ) ;
109+ expect ( serverSpan ?. attributes [ 'http.request.body.data' ] ) . toBeUndefined ( ) ;
105110 } ,
106111 } )
107112 . start ( ) ;
@@ -117,19 +122,17 @@ describe('express with httpIntegration and maxRequestBodySize: "none"', () => {
117122 test ( 'does not capture any request bodies with "none" setting and "ignoreRequestBody"' , async ( ) => {
118123 const runner = createRunner ( )
119124 . expect ( {
120- transaction : {
121- transaction : 'POST /test-body-size' ,
122- request : expect . not . objectContaining ( {
123- data : expect . any ( String ) ,
124- } ) ,
125+ span : container => {
126+ const serverSpan = container . items . find ( item => item . is_segment ) ;
127+ expect ( serverSpan ?. name ) . toBe ( 'POST /test-body-size' ) ;
128+ expect ( serverSpan ?. attributes [ 'http.request.body.data' ] ) . toBeUndefined ( ) ;
125129 } ,
126130 } )
127131 . expect ( {
128- transaction : {
129- transaction : 'POST /ignore-request-body' ,
130- request : expect . not . objectContaining ( {
131- data : expect . any ( String ) ,
132- } ) ,
132+ span : container => {
133+ const serverSpan = container . items . find ( item => item . is_segment ) ;
134+ expect ( serverSpan ?. name ) . toBe ( 'POST /ignore-request-body' ) ;
135+ expect ( serverSpan ?. attributes [ 'http.request.body.data' ] ) . toBeUndefined ( ) ;
133136 } ,
134137 } )
135138 . start ( ) ;
@@ -158,11 +161,13 @@ describe('express with httpIntegration and maxRequestBodySize: "always"', () =>
158161 test ( 'captures maximum allowed request body length with "always" setting' , async ( ) => {
159162 const runner = createRunner ( )
160163 . expect ( {
161- transaction : {
162- transaction : 'POST /test-body-size' ,
163- request : {
164- data : JSON . stringify ( generatePayload ( MAX_GENERAL ) ) ,
165- } ,
164+ span : container => {
165+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
166+ name : 'POST /test-body-size' ,
167+ attributes : expect . objectContaining ( {
168+ 'http.request.body.data' : { type : 'string' , value : JSON . stringify ( generatePayload ( MAX_GENERAL ) ) } ,
169+ } ) ,
170+ } ) ;
166171 } ,
167172 } )
168173 . start ( ) ;
@@ -178,11 +183,13 @@ describe('express with httpIntegration and maxRequestBodySize: "always"', () =>
178183 test ( 'captures large request bodies with "always" setting but respects maximum size limit' , async ( ) => {
179184 const runner = createRunner ( )
180185 . expect ( {
181- transaction : {
182- transaction : 'POST /test-body-size' ,
183- request : {
184- data : generatePayloadString ( MAX_GENERAL , true ) ,
185- } ,
186+ span : container => {
187+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
188+ name : 'POST /test-body-size' ,
189+ attributes : expect . objectContaining ( {
190+ 'http.request.body.data' : { type : 'string' , value : generatePayloadString ( MAX_GENERAL , true ) } ,
191+ } ) ,
192+ } ) ;
186193 } ,
187194 } )
188195 . start ( ) ;
@@ -206,11 +213,13 @@ describe('express with httpIntegration and maxRequestBodySize: "small"', () => {
206213 test ( 'keeps small request bodies with "small" setting' , async ( ) => {
207214 const runner = createRunner ( )
208215 . expect ( {
209- transaction : {
210- transaction : 'POST /test-body-size' ,
211- request : {
212- data : JSON . stringify ( generatePayload ( MAX_SMALL ) ) ,
213- } ,
216+ span : container => {
217+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
218+ name : 'POST /test-body-size' ,
219+ attributes : expect . objectContaining ( {
220+ 'http.request.body.data' : { type : 'string' , value : JSON . stringify ( generatePayload ( MAX_SMALL ) ) } ,
221+ } ) ,
222+ } ) ;
214223 } ,
215224 } )
216225 . start ( ) ;
@@ -226,11 +235,13 @@ describe('express with httpIntegration and maxRequestBodySize: "small"', () => {
226235 test ( 'truncates too large request bodies with "small" setting' , async ( ) => {
227236 const runner = createRunner ( )
228237 . expect ( {
229- transaction : {
230- transaction : 'POST /test-body-size' ,
231- request : {
232- data : generatePayloadString ( MAX_SMALL , true ) ,
233- } ,
238+ span : container => {
239+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
240+ name : 'POST /test-body-size' ,
241+ attributes : expect . objectContaining ( {
242+ 'http.request.body.data' : { type : 'string' , value : generatePayloadString ( MAX_SMALL , true ) } ,
243+ } ) ,
244+ } ) ;
234245 } ,
235246 } )
236247 . start ( ) ;
@@ -246,12 +257,14 @@ describe('express with httpIntegration and maxRequestBodySize: "small"', () => {
246257 test ( 'truncates too large non-ASCII request bodies with "small" setting' , async ( ) => {
247258 const runner = createRunner ( )
248259 . expect ( {
249- transaction : {
250- transaction : 'POST /test-body-size' ,
251- request : {
252- // 250 emojis, each 4 bytes in UTF-8 (resulting in 1000 bytes --> MAX_SMALL)
253- data : generateEmojiPayloadString ( 250 , true ) ,
254- } ,
260+ span : container => {
261+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
262+ name : 'POST /test-body-size' ,
263+ attributes : expect . objectContaining ( {
264+ // 250 emojis, each 4 bytes in UTF-8 (resulting in 1000 bytes --> MAX_SMALL)
265+ 'http.request.body.data' : { type : 'string' , value : generateEmojiPayloadString ( 250 , true ) } ,
266+ } ) ,
267+ } ) ;
255268 } ,
256269 } )
257270 . start ( ) ;
@@ -275,11 +288,13 @@ describe('express with httpIntegration and maxRequestBodySize: "medium"', () =>
275288 test ( 'keeps medium request bodies with "medium" setting' , async ( ) => {
276289 const runner = createRunner ( )
277290 . expect ( {
278- transaction : {
279- transaction : 'POST /test-body-size' ,
280- request : {
281- data : JSON . stringify ( generatePayload ( MAX_MEDIUM ) ) ,
282- } ,
291+ span : container => {
292+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
293+ name : 'POST /test-body-size' ,
294+ attributes : expect . objectContaining ( {
295+ 'http.request.body.data' : { type : 'string' , value : JSON . stringify ( generatePayload ( MAX_MEDIUM ) ) } ,
296+ } ) ,
297+ } ) ;
283298 } ,
284299 } )
285300 . start ( ) ;
@@ -295,11 +310,13 @@ describe('express with httpIntegration and maxRequestBodySize: "medium"', () =>
295310 test ( 'truncates large request bodies with "medium" setting' , async ( ) => {
296311 const runner = createRunner ( )
297312 . expect ( {
298- transaction : {
299- transaction : 'POST /test-body-size' ,
300- request : {
301- data : generatePayloadString ( MAX_MEDIUM , true ) ,
302- } ,
313+ span : container => {
314+ expect ( container . items . find ( item => item . is_segment ) ) . toMatchObject ( {
315+ name : 'POST /test-body-size' ,
316+ attributes : expect . objectContaining ( {
317+ 'http.request.body.data' : { type : 'string' , value : generatePayloadString ( MAX_MEDIUM , true ) } ,
318+ } ) ,
319+ } ) ;
303320 } ,
304321 } )
305322 . start ( ) ;
0 commit comments