File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -76,18 +76,24 @@ export function wrapRequestHandler(
76
76
// Note: This span will not have a duration unless I/O happens in the handler. This is
77
77
// because of how the cloudflare workers runtime works.
78
78
// See: https://developers.cloudflare.com/workers/runtime-apis/performance/
79
- return startSpan ( { name, attributes } , async ( span : Span ) => {
80
- try {
81
- const res = await handler ( ) ;
82
- setHttpStatus ( span , res . status ) ;
83
- return res ;
84
- } catch ( e ) {
85
- captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
86
- throw e ;
87
- } finally {
88
- context ?. waitUntil ( flush ( 2000 ) ) ;
89
- }
90
- } ) ;
79
+ return startSpan (
80
+ {
81
+ name,
82
+ attributes,
83
+ } ,
84
+ async span => {
85
+ try {
86
+ const res = await handler ( ) ;
87
+ setHttpStatus ( span , res . status ) ;
88
+ return res ;
89
+ } catch ( e ) {
90
+ captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
91
+ throw e ;
92
+ } finally {
93
+ context ?. waitUntil ( flush ( 2000 ) ) ;
94
+ }
95
+ } ,
96
+ ) ;
91
97
} ,
92
98
) ;
93
99
} ) ;
Original file line number Diff line number Diff line change @@ -220,6 +220,7 @@ describe('withSentry', () => {
220
220
trace_id : '12312012123120121231201212312012' ,
221
221
} ) ;
222
222
} ) ;
223
+
223
224
test ( 'creates a span that wraps request handler' , async ( ) => {
224
225
const mockRequest = new Request ( 'https://example.com' ) as any ;
225
226
mockRequest . cf = {
You can’t perform that action at this time.
0 commit comments