@@ -10,11 +10,15 @@ import {
10
10
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
11
11
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
12
12
browserTracingIntegration as originalBrowserTracingIntegration ,
13
+ getActiveSpan ,
14
+ getClient ,
13
15
getCurrentScope ,
16
+ getRootSpan ,
17
+ spanToJSON ,
14
18
startBrowserTracingNavigationSpan ,
19
+ startInactiveSpan ,
15
20
} from '@sentry/browser' ;
16
- import { getActiveSpan , getClient , getRootSpan , spanToJSON , startInactiveSpan } from '@sentry/core' ;
17
- import type { Integration , Span , Transaction } from '@sentry/types' ;
21
+ import type { Integration , Span } from '@sentry/types' ;
18
22
import { logger , stripUrlQueryAndFragment , timestampInSeconds } from '@sentry/utils' ;
19
23
import type { Observable } from 'rxjs' ;
20
24
import { Subscription } from 'rxjs' ;
@@ -59,16 +63,6 @@ export function _updateSpanAttributesForParametrizedUrl(route: string, span?: Sp
59
63
}
60
64
}
61
65
62
- /**
63
- * Grabs active transaction off scope.
64
- *
65
- * @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead.
66
- */
67
- export function getActiveTransaction ( ) : Transaction | undefined {
68
- // eslint-disable-next-line deprecation/deprecation
69
- return getCurrentScope ( ) . getTransaction ( ) ;
70
- }
71
-
72
66
/**
73
67
* Angular's Service responsible for hooking into Angular Router and tracking current navigation process.
74
68
* Creates a new transaction for every route change and measures a duration of routing process.
@@ -293,21 +287,19 @@ export function TraceClassDecorator(): ClassDecorator {
293
287
let tracingSpan : Span ;
294
288
295
289
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
296
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
297
290
return target => {
298
291
const originalOnInit = target . prototype . ngOnInit ;
299
292
// eslint-disable-next-line @typescript-eslint/no-explicit-any
300
293
target . prototype . ngOnInit = function ( ...args : any [ ] ) : ReturnType < typeof originalOnInit > {
301
- // eslint-disable-next-line deprecation/deprecation
302
- const activeTransaction = getActiveTransaction ( ) ;
303
- if ( activeTransaction ) {
304
- // eslint-disable-next-line deprecation/deprecation
305
- tracingSpan = activeTransaction . startChild ( {
306
- name : `<${ target . name } >` ,
307
- op : ANGULAR_INIT_OP ,
308
- origin : 'auto.ui.angular.trace_class_decorator' ,
309
- } ) ;
310
- }
294
+ tracingSpan = startInactiveSpan ( {
295
+ onlyIfParent : true ,
296
+ name : `<${ target . name } >` ,
297
+ op : ANGULAR_INIT_OP ,
298
+ attributes : {
299
+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_class_decorator' ,
300
+ } ,
301
+ } ) ;
302
+
311
303
if ( originalOnInit ) {
312
304
return originalOnInit . apply ( this , args ) ;
313
305
}
@@ -331,24 +323,23 @@ export function TraceClassDecorator(): ClassDecorator {
331
323
* Decorator function that can be used to capture a single lifecycle methods of the component.
332
324
*/
333
325
export function TraceMethodDecorator ( ) : MethodDecorator {
334
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ ban-types
326
+ // eslint-disable-next-line @typescript-eslint/ban-types
335
327
return ( target : Object , propertyKey : string | symbol , descriptor : PropertyDescriptor ) => {
336
328
const originalMethod = descriptor . value ;
337
329
// eslint-disable-next-line @typescript-eslint/no-explicit-any
338
330
descriptor . value = function ( ...args : any [ ] ) : ReturnType < typeof originalMethod > {
339
331
const now = timestampInSeconds ( ) ;
340
- // eslint-disable-next-line deprecation/deprecation
341
- const activeTransaction = getActiveTransaction ( ) ;
342
- if ( activeTransaction ) {
343
- // eslint-disable-next-line deprecation/deprecation
344
- activeTransaction . startChild ( {
345
- name : `<${ target . constructor . name } >` ,
346
- endTimestamp : now ,
347
- op : `${ ANGULAR_OP } .${ String ( propertyKey ) } ` ,
348
- origin : 'auto.ui.angular.trace_method_decorator' ,
349
- startTimestamp : now ,
350
- } ) ;
351
- }
332
+
333
+ startInactiveSpan ( {
334
+ onlyIfParent : true ,
335
+ name : `<${ target . constructor . name } >` ,
336
+ op : `${ ANGULAR_OP } .${ String ( propertyKey ) } ` ,
337
+ startTime : now ,
338
+ attributes : {
339
+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.angular.trace_method_decorator' ,
340
+ } ,
341
+ } ) . end ( now ) ;
342
+
352
343
if ( originalMethod ) {
353
344
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
354
345
return originalMethod . apply ( this , args ) ;
0 commit comments