@@ -20,24 +20,24 @@ export function registerSpanErrorInstrumentation(): void {
20
20
return ;
21
21
}
22
22
23
+ /**
24
+ * If an error or unhandled promise occurs, we mark the active root span as failed
25
+ */
26
+ function errorCallback ( ) : void {
27
+ const activeSpan = getActiveSpan ( ) ;
28
+ const rootSpan = activeSpan && getRootSpan ( activeSpan ) ;
29
+ if ( rootSpan ) {
30
+ const message = 'internal_error' ;
31
+ DEBUG_BUILD && debug . log ( `[Tracing] Root span: ${ message } -> Global error occurred` ) ;
32
+ rootSpan . setStatus ( { code : SPAN_STATUS_ERROR , message } ) ;
33
+ }
34
+ }
35
+
36
+ // The function name will be lost when bundling but we need to be able to identify this listener later to maintain the
37
+ // node.js default exit behaviour
38
+ errorCallback . tag = 'sentry_tracingErrorCallback' ;
39
+
23
40
errorsInstrumented = true ;
24
41
addGlobalErrorInstrumentationHandler ( errorCallback ) ;
25
42
addGlobalUnhandledRejectionInstrumentationHandler ( errorCallback ) ;
26
43
}
27
-
28
- /**
29
- * If an error or unhandled promise occurs, we mark the active root span as failed
30
- */
31
- function errorCallback ( ) : void {
32
- const activeSpan = getActiveSpan ( ) ;
33
- const rootSpan = activeSpan && getRootSpan ( activeSpan ) ;
34
- if ( rootSpan ) {
35
- const message = 'internal_error' ;
36
- DEBUG_BUILD && debug . log ( `[Tracing] Root span: ${ message } -> Global error occurred` ) ;
37
- rootSpan . setStatus ( { code : SPAN_STATUS_ERROR , message } ) ;
38
- }
39
- }
40
-
41
- // The function name will be lost when bundling but we need to be able to identify this listener later to maintain the
42
- // node.js default exit behaviour
43
- errorCallback . tag = 'sentry_tracingErrorCallback' ;
0 commit comments