File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ export class MetricsListener {
56
56
57
57
constructor ( private kmsClient : KMSService , private config : MetricsConfig ) {
58
58
this . apiKey = this . getAPIKey ( config ) ;
59
+ this . config = config ;
59
60
}
60
61
61
62
public async onStartInvocation ( _ : any ) {
@@ -143,6 +144,11 @@ export class MetricsListener {
143
144
144
145
const dist = new Distribution ( name , [ { timestamp : metricTime , value } ] , ...tags ) ;
145
146
147
+ if ( ! this . apiKey ) {
148
+ const errorMessage = "api key not configured, see https://dtdg.co/sls-node-metrics" ;
149
+ logError ( errorMessage ) ;
150
+ return ;
151
+ }
146
152
if ( this . currentProcessor !== undefined ) {
147
153
// tslint:disable-next-line: no-floating-promises
148
154
this . currentProcessor . then ( ( processor ) => {
@@ -179,13 +185,6 @@ export class MetricsListener {
179
185
logError ( "couldn't decrypt kms api key" , error as Error ) ;
180
186
}
181
187
}
182
- } else {
183
- const errorMessage = "api key not configured, see https://dtdg.co/sls-node-metrics" ;
184
- if ( config . logForwarding || this . isAgentRunning ) {
185
- logDebug ( errorMessage ) ;
186
- } else {
187
- logError ( errorMessage ) ;
188
- }
189
188
}
190
189
return "" ;
191
190
}
You can’t perform that action at this time.
0 commit comments