@@ -53,7 +53,7 @@ class MonitorManager {
53
53
setup ( {
54
54
level = 'info' ,
55
55
patchGlobal = true ,
56
- bailOnUnhandledRejection = false ,
56
+ bailOnUnhandledRejection = true ,
57
57
resourceInterval = 60 ,
58
58
mock = false ,
59
59
enable = true ,
@@ -69,13 +69,12 @@ class MonitorManager {
69
69
}
70
70
this . alreadySetup = true ;
71
71
72
- if ( ! enable ) {
72
+ if ( ! enable || mock ) {
73
73
patchGlobal = false ;
74
74
processName = null ;
75
75
}
76
76
77
77
this . mock = mock ;
78
- this . enable = enable ;
79
78
this . pretty = pretty ;
80
79
this . subject = 'root' ;
81
80
this . metadata = metadata ;
@@ -130,7 +129,6 @@ class MonitorManager {
130
129
name : `taskcluster.${ this . serviceName } .${ this . subject } ` ,
131
130
service : this . serviceName ,
132
131
level : this . levels [ 'root' ] ,
133
- enable,
134
132
pretty,
135
133
destination : this . destination ,
136
134
metadata,
@@ -139,19 +137,18 @@ class MonitorManager {
139
137
this . rootMonitor = new Monitor ( {
140
138
logger,
141
139
verify,
142
- enable,
143
140
types : this . types ,
144
141
} ) ;
145
142
146
- if ( patchGlobal && enable ) {
143
+ if ( patchGlobal ) {
147
144
this . uncaughtExceptionHandler = this . _uncaughtExceptionHandler . bind ( this ) ;
148
145
process . on ( 'uncaughtException' , this . uncaughtExceptionHandler ) ;
149
146
150
147
this . unhandledRejectionHandler = this . _unhandledRejectionHandler . bind ( this ) ;
151
148
process . on ( 'unhandledRejection' , this . unhandledRejectionHandler ) ;
152
149
}
153
150
154
- if ( processName && ! mock && enable ) {
151
+ if ( processName ) {
155
152
this . rootMonitor . resources ( processName , resourceInterval ) ;
156
153
}
157
154
@@ -177,8 +174,12 @@ class MonitorManager {
177
174
*/
178
175
terminate ( ) {
179
176
this . rootMonitor . stopResourceMonitoring ( ) ;
180
- process . removeListener ( 'uncaughtException' , this . uncaughtExceptionHandler ) ;
181
- process . removeListener ( 'unhandledRejection' , this . unhandledRejectionHandler ) ;
177
+ if ( this . uncaughtExceptionHandler ) {
178
+ process . removeListener ( 'uncaughtException' , this . uncaughtExceptionHandler ) ;
179
+ }
180
+ if ( this . unhandledRejectionHandler ) {
181
+ process . removeListener ( 'unhandledRejection' , this . unhandledRejectionHandler ) ;
182
+ }
182
183
if ( this . mock ) {
183
184
this . destination . end ( ) ;
184
185
}
@@ -204,12 +205,10 @@ class MonitorManager {
204
205
return new Monitor ( {
205
206
types : this . types ,
206
207
verify : this . verify ,
207
- enable : this . enable ,
208
208
logger : new Logger ( {
209
209
name : `taskcluster.${ this . serviceName } .${ prefix } ` ,
210
210
service : this . serviceName ,
211
211
level : this . levels [ prefix ] || this . levels . root ,
212
- enable : this . enable ,
213
212
pretty : this . pretty ,
214
213
destination : this . destination ,
215
214
metadata,
0 commit comments