@@ -54,14 +54,7 @@ export function getActiveTransaction(): Transaction | undefined {
54
54
*/
55
55
@Injectable ( { providedIn : 'root' } )
56
56
export class TraceService {
57
- private routingSpan ?: Span ;
58
-
59
- public constructor ( private readonly router : Router ) {
60
- this . navStart$ . subscribe ( ) ;
61
- this . navEnd$ . subscribe ( ) ;
62
- }
63
-
64
- public navStart$ : Observable < Event > = this . router . events . pipe (
57
+ public navStart$ : Observable < Event > = this . _router . events . pipe (
65
58
filter ( event => event instanceof NavigationStart ) ,
66
59
tap ( event => {
67
60
if ( ! instrumentationInitialized ) {
@@ -80,7 +73,7 @@ export class TraceService {
80
73
}
81
74
82
75
if ( activeTransaction ) {
83
- this . routingSpan = activeTransaction . startChild ( {
76
+ this . _routingSpan = activeTransaction . startChild ( {
84
77
description : `${ navigationEvent . url } ` ,
85
78
op : `angular.routing` ,
86
79
tags : {
@@ -95,15 +88,22 @@ export class TraceService {
95
88
} ) ,
96
89
) ;
97
90
98
- public navEnd$ : Observable < Event > = this . router . events . pipe (
91
+ public navEnd$ : Observable < Event > = this . _router . events . pipe (
99
92
filter ( event => event instanceof NavigationEnd ) ,
100
93
tap ( ( ) => {
101
- if ( this . routingSpan ) {
102
- this . routingSpan . finish ( ) ;
103
- delete this . routingSpan ;
94
+ if ( this . _routingSpan ) {
95
+ this . _routingSpan . finish ( ) ;
96
+ delete this . _routingSpan ;
104
97
}
105
98
} ) ,
106
99
) ;
100
+
101
+ private _routingSpan ?: Span ;
102
+
103
+ public constructor ( private readonly _router : Router ) {
104
+ this . navStart$ . subscribe ( ) ;
105
+ this . navEnd$ . subscribe ( ) ;
106
+ }
107
107
}
108
108
109
109
const UNKNOWN_COMPONENT = 'unknown' ;
@@ -113,18 +113,18 @@ const UNKNOWN_COMPONENT = 'unknown';
113
113
*/
114
114
@Directive ( { selector : '[trace]' } )
115
115
export class TraceDirective implements OnInit , AfterViewInit {
116
- private tracingSpan ?: Span ;
117
-
118
116
@Input ( 'trace' ) public componentName : string = UNKNOWN_COMPONENT ;
119
117
118
+ private _tracingSpan ?: Span ;
119
+
120
120
/**
121
121
* Implementation of OnInit lifecycle method
122
122
* @inheritdoc
123
123
*/
124
124
public ngOnInit ( ) : void {
125
125
const activeTransaction = getActiveTransaction ( ) ;
126
126
if ( activeTransaction ) {
127
- this . tracingSpan = activeTransaction . startChild ( {
127
+ this . _tracingSpan = activeTransaction . startChild ( {
128
128
description : `<${ this . componentName } >` ,
129
129
op : `angular.initialize` ,
130
130
} ) ;
@@ -136,8 +136,8 @@ export class TraceDirective implements OnInit, AfterViewInit {
136
136
* @inheritdoc
137
137
*/
138
138
public ngAfterViewInit ( ) : void {
139
- if ( this . tracingSpan ) {
140
- this . tracingSpan . finish ( ) ;
139
+ if ( this . _tracingSpan ) {
140
+ this . _tracingSpan . finish ( ) ;
141
141
}
142
142
}
143
143
}
@@ -148,10 +148,11 @@ export class TraceDirective implements OnInit, AfterViewInit {
148
148
export function TraceClassDecorator ( ) : ClassDecorator {
149
149
let tracingSpan : Span ;
150
150
151
- return ( target : Function ) => {
151
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
152
+ return target => {
152
153
// tslint:disable-next-line:no-unsafe-any
153
154
const originalOnInit = target . prototype . ngOnInit ;
154
- // tslint: disable-next-line: no-unsafe -any
155
+ // eslint- disable-next-line @typescript-eslint/ no-explicit -any
155
156
target . prototype . ngOnInit = function ( ...args : any [ ] ) : ReturnType < typeof originalOnInit > {
156
157
const activeTransaction = getActiveTransaction ( ) ;
157
158
if ( activeTransaction ) {
@@ -161,14 +162,12 @@ export function TraceClassDecorator(): ClassDecorator {
161
162
} ) ;
162
163
}
163
164
if ( originalOnInit ) {
164
- // tslint:disable-next-line:no-unsafe-any
165
165
return originalOnInit . apply ( this , args ) ;
166
166
}
167
167
} ;
168
168
169
- // tslint:disable-next-line:no-unsafe-any
170
169
const originalAfterViewInit = target . prototype . ngAfterViewInit ;
171
- // tslint: disable-next-line: no-unsafe -any
170
+ // eslint- disable-next-line @typescript-eslint/ no-explicit -any
172
171
target . prototype . ngAfterViewInit = function ( ...args : any [ ] ) : ReturnType < typeof originalAfterViewInit > {
173
172
if ( tracingSpan ) {
174
173
tracingSpan . finish ( ) ;
@@ -185,8 +184,10 @@ export function TraceClassDecorator(): ClassDecorator {
185
184
* Decorator function that can be used to capture a single lifecycle methods of the component.
186
185
*/
187
186
export function TraceMethodDecorator ( ) : MethodDecorator {
187
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types
188
188
return ( target : Object , propertyKey : string | symbol , descriptor : PropertyDescriptor ) => {
189
189
const originalMethod = descriptor . value ;
190
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
191
descriptor . value = function ( ...args : any [ ] ) : ReturnType < typeof originalMethod > {
191
192
const now = timestampWithMs ( ) ;
192
193
const activeTransaction = getActiveTransaction ( ) ;
0 commit comments