@@ -12,7 +12,6 @@ test('Sends an API route transaction', async ({ baseURL }) => {
12
12
await fetch ( `${ baseURL } /test-transaction` ) ;
13
13
14
14
const transactionEvent = await pageloadTransactionEventPromise ;
15
- const transactionEventId = transactionEvent . event_id ;
16
15
17
16
expect ( transactionEvent . contexts ?. trace ) . toEqual ( {
18
17
data : {
@@ -119,3 +118,84 @@ test('Sends an API route transaction', async ({ baseURL }) => {
119
118
trace_id : expect . any ( String ) ,
120
119
} ) ;
121
120
} ) ;
121
+
122
+ test ( 'Sends an API route transaction for an errored route' , async ( { baseURL } ) => {
123
+ const transactionEventPromise = waitForTransaction ( 'node-express' , transactionEvent => {
124
+ return (
125
+ transactionEvent . contexts ?. trace ?. op === 'http.server' &&
126
+ transactionEvent . transaction === 'GET /test-exception/:id' &&
127
+ transactionEvent . request ?. url === 'http://localhost:3030/test-exception/777'
128
+ ) ;
129
+ } ) ;
130
+
131
+ await fetch ( `${ baseURL } /test-exception/777` ) ;
132
+
133
+ const transactionEvent = await transactionEventPromise ;
134
+
135
+ expect ( transactionEvent . contexts ?. trace ?. op ) . toEqual ( 'http.server' ) ;
136
+ expect ( transactionEvent . transaction ) . toEqual ( 'GET /test-exception/:id' ) ;
137
+ expect ( transactionEvent . contexts ?. trace ?. status ) . toEqual ( 'internal_error' ) ;
138
+ expect ( transactionEvent . contexts ?. trace ?. data ?. [ 'http.status_code' ] ) . toEqual ( 500 ) ;
139
+
140
+ const spans = transactionEvent . spans || [ ] ;
141
+
142
+ expect ( spans ) . toContainEqual ( {
143
+ data : {
144
+ 'sentry.origin' : 'auto.http.otel.express' ,
145
+ 'sentry.op' : 'middleware.express' ,
146
+ 'http.route' : '/' ,
147
+ 'express.name' : 'query' ,
148
+ 'express.type' : 'middleware' ,
149
+ 'otel.kind' : 'INTERNAL' ,
150
+ } ,
151
+ description : 'query' ,
152
+ op : 'middleware.express' ,
153
+ origin : 'auto.http.otel.express' ,
154
+ parent_span_id : expect . any ( String ) ,
155
+ span_id : expect . any ( String ) ,
156
+ start_timestamp : expect . any ( Number ) ,
157
+ status : 'ok' ,
158
+ timestamp : expect . any ( Number ) ,
159
+ trace_id : expect . any ( String ) ,
160
+ } ) ;
161
+
162
+ expect ( spans ) . toContainEqual ( {
163
+ data : {
164
+ 'sentry.origin' : 'auto.http.otel.express' ,
165
+ 'sentry.op' : 'middleware.express' ,
166
+ 'http.route' : '/' ,
167
+ 'express.name' : 'expressInit' ,
168
+ 'express.type' : 'middleware' ,
169
+ 'otel.kind' : 'INTERNAL' ,
170
+ } ,
171
+ description : 'expressInit' ,
172
+ op : 'middleware.express' ,
173
+ origin : 'auto.http.otel.express' ,
174
+ parent_span_id : expect . any ( String ) ,
175
+ span_id : expect . any ( String ) ,
176
+ start_timestamp : expect . any ( Number ) ,
177
+ status : 'ok' ,
178
+ timestamp : expect . any ( Number ) ,
179
+ trace_id : expect . any ( String ) ,
180
+ } ) ;
181
+
182
+ expect ( spans ) . toContainEqual ( {
183
+ data : {
184
+ 'sentry.origin' : 'auto.http.otel.express' ,
185
+ 'sentry.op' : 'request_handler.express' ,
186
+ 'http.route' : '/test-exception/:id' ,
187
+ 'express.name' : '/test-exception/:id' ,
188
+ 'express.type' : 'request_handler' ,
189
+ 'otel.kind' : 'INTERNAL' ,
190
+ } ,
191
+ description : '/test-exception/:id' ,
192
+ op : 'request_handler.express' ,
193
+ origin : 'auto.http.otel.express' ,
194
+ parent_span_id : expect . any ( String ) ,
195
+ span_id : expect . any ( String ) ,
196
+ start_timestamp : expect . any ( Number ) ,
197
+ status : 'ok' ,
198
+ timestamp : expect . any ( Number ) ,
199
+ trace_id : expect . any ( String ) ,
200
+ } ) ;
201
+ } ) ;
0 commit comments