@@ -7,50 +7,55 @@ const { performance } = require('perf_hooks')
7
7
// start/error/finish methods to the appropriate diagnostic channels.
8
8
// TODO: Decouple this from TracingPlugin.
9
9
class EventPlugin extends TracingPlugin {
10
+ #eventHandler
11
+ #eventFilter
12
+ #dataSymbol
13
+ #entryType
14
+
10
15
constructor ( eventHandler , eventFilter ) {
11
16
super ( )
12
- this . eventHandler = eventHandler
13
- this . eventFilter = eventFilter
14
- this . entryType = this . constructor . entryType
15
- this . dataSymbol = Symbol ( `dd-trace.profiling.event.${ this . entryType } .${ this . constructor . operation } ` )
17
+ this . # eventHandler = eventHandler
18
+ this . # eventFilter = eventFilter
19
+ this . # entryType = this . constructor . entryType
20
+ this . # dataSymbol = Symbol ( `dd-trace.profiling.event.${ this . # entryType} .${ this . constructor . operation } ` )
16
21
}
17
22
18
23
start ( ctx ) {
19
- ctx [ this . dataSymbol ] = performance . now ( )
24
+ ctx [ this . # dataSymbol] = performance . now ( )
20
25
}
21
26
22
27
error ( ctx ) {
23
28
// We don't emit perf events for failed operations
24
- ctx [ this . dataSymbol ] = undefined
29
+ ctx [ this . # dataSymbol] = undefined
25
30
}
26
31
27
32
finish ( ctx ) {
28
- const startTime = ctx [ this . dataSymbol ]
33
+ const startTime = ctx [ this . # dataSymbol]
29
34
if ( startTime === undefined ) {
30
35
return
31
36
}
32
- ctx [ this . dataSymbol ] = undefined
37
+ ctx [ this . # dataSymbol] = undefined
33
38
34
39
if ( this . ignoreEvent ( ctx ) ) {
35
40
return // don't emit perf events for ignored events
36
41
}
37
42
38
43
const duration = performance . now ( ) - startTime
39
44
const event = {
40
- entryType : this . entryType ,
45
+ entryType : this . # entryType,
41
46
startTime,
42
47
duration
43
48
}
44
49
45
- if ( ! this . eventFilter ( event ) ) {
50
+ if ( ! this . # eventFilter( event ) ) {
46
51
return
47
52
}
48
53
49
54
const context = ( ctx . currentStore ?. span || this . activeSpan ) ?. context ( )
50
55
event . _ddSpanId = context ?. toSpanId ( )
51
56
event . _ddRootSpanId = context ?. _trace . started [ 0 ] ?. context ( ) . toSpanId ( ) || event . _ddSpanId
52
57
53
- this . eventHandler ( this . extendEvent ( event , ctx ) )
58
+ this . # eventHandler( this . extendEvent ( event , ctx ) )
54
59
}
55
60
56
61
ignoreEvent ( ) {
0 commit comments