File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/apm/src/integrations Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,27 @@ export class Tracing implements Integration {
211
211
} ) ;
212
212
}
213
213
214
+ /**
215
+ * If an error or unhandled promise occurs, we mark the active transaction as failed
216
+ */
217
+ // tslint:disable-next-line: completed-docs
218
+ function errorCallback ( ) : void {
219
+ if ( Tracing . _activeTransaction ) {
220
+ logger . log ( `[Tracing] Global error occured, setting status in transaction: ${ SpanStatus . InternalError } ` ) ;
221
+ ( Tracing . _activeTransaction as SpanClass ) . setStatus ( SpanStatus . InternalError ) ;
222
+ }
223
+ }
224
+
225
+ addInstrumentationHandler ( {
226
+ callback : errorCallback ,
227
+ type : 'error' ,
228
+ } ) ;
229
+
230
+ addInstrumentationHandler ( {
231
+ callback : errorCallback ,
232
+ type : 'unhandledrejection' ,
233
+ } ) ;
234
+
214
235
if ( Tracing . options . discardBackgroundSpans && global . document ) {
215
236
document . addEventListener ( 'visibilitychange' , ( ) => {
216
237
if ( document . hidden && Tracing . _activeTransaction ) {
You can’t perform that action at this time.
0 commit comments