@@ -144,12 +144,12 @@ class Tracer implements TracerInterface {
144
144
* @param error - Error to serialize as metadata
145
145
*/
146
146
public addErrorAsMetadata ( error : Error ) : void {
147
- if ( this . isTracingEnabled ( ) === false ) {
147
+ if ( ! this . isTracingEnabled ( ) ) {
148
148
return ;
149
149
}
150
150
151
151
const subsegment = this . getSegment ( ) ;
152
- if ( this . captureError === false ) {
152
+ if ( ! this . captureError ) {
153
153
subsegment . addErrorFlag ( ) ;
154
154
155
155
return ;
@@ -167,7 +167,7 @@ class Tracer implements TracerInterface {
167
167
* @param methodName - Name of the method that is being traced
168
168
*/
169
169
public addResponseAsMetadata ( data ?: unknown , methodName ?: string ) : void {
170
- if ( data === undefined || this . captureResponse === false || this . isTracingEnabled ( ) === false ) {
170
+ if ( data === undefined || ! this . captureResponse || ! this . isTracingEnabled ( ) ) {
171
171
return ;
172
172
}
173
173
@@ -179,7 +179,7 @@ class Tracer implements TracerInterface {
179
179
*
180
180
*/
181
181
public addServiceNameAnnotation ( ) : void {
182
- if ( this . isTracingEnabled ( ) === false || this . serviceName === undefined ) {
182
+ if ( ! this . isTracingEnabled ( ) || this . serviceName === undefined ) {
183
183
return ;
184
184
}
185
185
this . putAnnotation ( 'Service' , this . serviceName ) ;
@@ -188,17 +188,17 @@ class Tracer implements TracerInterface {
188
188
/**
189
189
* Add ColdStart annotation to the current segment or subsegment.
190
190
*
191
- * If Tracer has been initialized outside of the Lambda handler then the same instance
192
- * of Tracer will be reused throghout the lifecycle of that same Lambda execution environment
191
+ * If Tracer has been initialized outside the Lambda handler then the same instance
192
+ * of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
193
193
* and this method will annotate `ColdStart: false` after the first invocation.
194
194
*
195
195
* @see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
196
196
*/
197
197
public annotateColdStart ( ) : void {
198
- if ( this . isTracingEnabled ( ) === true ) {
198
+ if ( this . isTracingEnabled ( ) ) {
199
199
this . putAnnotation ( 'ColdStart' , Tracer . coldStart ) ;
200
200
}
201
- if ( Tracer . coldStart === true ) {
201
+ if ( Tracer . coldStart ) {
202
202
Tracer . coldStart = false ;
203
203
}
204
204
}
@@ -226,7 +226,7 @@ class Tracer implements TracerInterface {
226
226
* @returns AWS - Instrumented AWS SDK
227
227
*/
228
228
public captureAWS < T > ( aws : T ) : T {
229
- if ( this . isTracingEnabled ( ) === false ) return aws ;
229
+ if ( ! this . isTracingEnabled ( ) ) return aws ;
230
230
231
231
return this . provider . captureAWS ( aws ) ;
232
232
}
@@ -255,7 +255,7 @@ class Tracer implements TracerInterface {
255
255
* @returns service - Instrumented AWS SDK v2 client
256
256
*/
257
257
public captureAWSClient < T > ( service : T ) : T {
258
- if ( this . isTracingEnabled ( ) === false ) return service ;
258
+ if ( ! this . isTracingEnabled ( ) ) return service ;
259
259
260
260
return this . provider . captureAWSClient ( service ) ;
261
261
}
@@ -285,7 +285,7 @@ class Tracer implements TracerInterface {
285
285
* @returns service - Instrumented AWS SDK v3 client
286
286
*/
287
287
public captureAWSv3Client < T > ( service : T ) : T {
288
- if ( this . isTracingEnabled ( ) === false ) return service ;
288
+ if ( ! this . isTracingEnabled ( ) ) return service ;
289
289
290
290
return this . provider . captureAWSv3Client ( service ) ;
291
291
}
@@ -326,7 +326,7 @@ class Tracer implements TracerInterface {
326
326
const originalMethod = descriptor . value ;
327
327
328
328
descriptor . value = ( ( event , context , callback ) => {
329
- if ( this . isTracingEnabled ( ) === false ) {
329
+ if ( ! this . isTracingEnabled ( ) ) {
330
330
return originalMethod ?. apply ( target , [ event , context , callback ] ) ;
331
331
}
332
332
@@ -393,7 +393,7 @@ class Tracer implements TracerInterface {
393
393
const originalMethod = descriptor . value ;
394
394
395
395
descriptor . value = ( ...args : unknown [ ] ) => {
396
- if ( this . isTracingEnabled ( ) === false ) {
396
+ if ( ! this . isTracingEnabled ( ) ) {
397
397
return originalMethod ?. apply ( target , [ ...args ] ) ;
398
398
}
399
399
@@ -421,16 +421,16 @@ class Tracer implements TracerInterface {
421
421
/**
422
422
* Retrieve the current value of `ColdStart`.
423
423
*
424
- * If Tracer has been initialized outside of the Lambda handler then the same instance
425
- * of Tracer will be reused throghout the lifecycle of that same Lambda execution environment
424
+ * If Tracer has been initialized outside the Lambda handler then the same instance
425
+ * of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
426
426
* and this method will return `false` after the first invocation.
427
427
*
428
428
* @see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
429
429
*
430
430
* @returns boolean - `true` if is cold start, otherwise `false`
431
431
*/
432
432
public static getColdStart ( ) : boolean {
433
- if ( Tracer . coldStart === true ) {
433
+ if ( Tracer . coldStart ) {
434
434
Tracer . coldStart = false ;
435
435
436
436
return true ;
@@ -505,7 +505,7 @@ class Tracer implements TracerInterface {
505
505
* @param value - Value for annotation
506
506
*/
507
507
public putAnnotation ( key : string , value : string | number | boolean ) : void {
508
- if ( this . isTracingEnabled ( ) === false ) return ;
508
+ if ( ! this . isTracingEnabled ( ) ) return ;
509
509
510
510
const document = this . getSegment ( ) ;
511
511
if ( document instanceof Segment ) {
@@ -535,10 +535,10 @@ class Tracer implements TracerInterface {
535
535
*
536
536
* @param key - Metadata key
537
537
* @param value - Value for metadata
538
- * @param timestamp - Namespace that metadata will lie under, if none is passed it will use the serviceName
538
+ * @param namespace - Namespace that metadata will lie under, if none is passed it will use the serviceName
539
539
*/
540
540
public putMetadata ( key : string , value : unknown , namespace ?: string | undefined ) : void {
541
- if ( this . isTracingEnabled ( ) === false ) return ;
541
+ if ( ! this . isTracingEnabled ( ) ) return ;
542
542
543
543
const document = this . getSegment ( ) ;
544
544
if ( document instanceof Segment ) {
@@ -617,7 +617,7 @@ class Tracer implements TracerInterface {
617
617
*
618
618
* @param serviceName - Service name to validate
619
619
*/
620
- private isValidServiceName ( serviceName ?: string ) : boolean {
620
+ private static isValidServiceName ( serviceName ?: string ) : boolean {
621
621
return typeof serviceName === 'string' && serviceName . trim ( ) . length > 0 ;
622
622
}
623
623
@@ -709,21 +709,21 @@ class Tracer implements TracerInterface {
709
709
* @param serviceName - Name of the service to use
710
710
*/
711
711
private setServiceName ( serviceName ?: string ) : void {
712
- if ( serviceName !== undefined && this . isValidServiceName ( serviceName ) ) {
712
+ if ( serviceName !== undefined && Tracer . isValidServiceName ( serviceName ) ) {
713
713
this . serviceName = serviceName ;
714
714
715
715
return ;
716
716
}
717
717
718
718
const customConfigValue = this . getCustomConfigService ( ) ?. getServiceName ( ) ;
719
- if ( customConfigValue !== undefined && this . isValidServiceName ( customConfigValue ) ) {
719
+ if ( customConfigValue !== undefined && Tracer . isValidServiceName ( customConfigValue ) ) {
720
720
this . serviceName = customConfigValue ;
721
721
722
722
return ;
723
723
}
724
724
725
725
const envVarsValue = this . getEnvVarsService ( ) ?. getServiceName ( ) ;
726
- if ( envVarsValue !== undefined && this . isValidServiceName ( envVarsValue ) ) {
726
+ if ( envVarsValue !== undefined && Tracer . isValidServiceName ( envVarsValue ) ) {
727
727
this . serviceName = envVarsValue ;
728
728
729
729
return ;
@@ -737,7 +737,7 @@ class Tracer implements TracerInterface {
737
737
* @param enabled - Whether or not tracing is enabled
738
738
*/
739
739
private setTracingEnabled ( enabled ?: boolean ) : void {
740
- if ( enabled !== undefined && enabled === false ) {
740
+ if ( enabled !== undefined && ! enabled ) {
741
741
this . tracingEnabled = enabled ;
742
742
743
743
return ;
@@ -757,7 +757,7 @@ class Tracer implements TracerInterface {
757
757
return ;
758
758
}
759
759
760
- if ( this . isLambdaSamCli ( ) || this . isLambdaExecutionEnv ( ) === false ) {
760
+ if ( this . isLambdaSamCli ( ) || ! this . isLambdaExecutionEnv ( ) ) {
761
761
this . tracingEnabled = false ;
762
762
}
763
763
}
0 commit comments