@@ -140,12 +140,12 @@ class Tracer implements TracerInterface {
140
140
* @param error - Error to serialize as metadata
141
141
*/
142
142
public addErrorAsMetadata ( error : Error ) : void {
143
- if ( this . tracingEnabled === false ) {
143
+ if ( ! this . tracingEnabled ) {
144
144
return ;
145
145
}
146
146
147
147
const subsegment = this . getSegment ( ) ;
148
- if ( this . captureError === false ) {
148
+ if ( ! this . captureError ) {
149
149
subsegment . addErrorFlag ( ) ;
150
150
151
151
return ;
@@ -163,7 +163,7 @@ class Tracer implements TracerInterface {
163
163
* @param methodName - Name of the method that is being traced
164
164
*/
165
165
public addResponseAsMetadata ( data ?: unknown , methodName ?: string ) : void {
166
- if ( data === undefined || this . captureResponse === false || this . tracingEnabled === false ) {
166
+ if ( data === undefined || ! this . captureResponse || ! this . tracingEnabled ) {
167
167
return ;
168
168
}
169
169
@@ -175,7 +175,7 @@ class Tracer implements TracerInterface {
175
175
*
176
176
*/
177
177
public addServiceNameAnnotation ( ) : void {
178
- if ( this . tracingEnabled === false || this . serviceName === undefined ) {
178
+ if ( ! this . tracingEnabled || this . serviceName === undefined ) {
179
179
return ;
180
180
}
181
181
this . putAnnotation ( 'Service' , this . serviceName ) ;
@@ -184,17 +184,17 @@ class Tracer implements TracerInterface {
184
184
/**
185
185
* Add ColdStart annotation to the current segment or subsegment.
186
186
*
187
- * If Tracer has been initialized outside of the Lambda handler then the same instance
188
- * of Tracer will be reused throghout the lifecycle of that same Lambda execution environment
187
+ * If Tracer has been initialized outside the Lambda handler then the same instance
188
+ * of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
189
189
* and this method will annotate `ColdStart: false` after the first invocation.
190
190
*
191
191
* @see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
192
192
*/
193
193
public annotateColdStart ( ) : void {
194
- if ( this . tracingEnabled === true ) {
194
+ if ( this . tracingEnabled ) {
195
195
this . putAnnotation ( 'ColdStart' , Tracer . coldStart ) ;
196
196
}
197
- if ( Tracer . coldStart === true ) {
197
+ if ( Tracer . coldStart ) {
198
198
Tracer . coldStart = false ;
199
199
}
200
200
}
@@ -222,7 +222,7 @@ class Tracer implements TracerInterface {
222
222
* @returns AWS - Instrumented AWS SDK
223
223
*/
224
224
public captureAWS < T > ( aws : T ) : T {
225
- if ( this . tracingEnabled === false ) return aws ;
225
+ if ( ! this . tracingEnabled ) return aws ;
226
226
227
227
return this . provider . captureAWS ( aws ) ;
228
228
}
@@ -251,7 +251,7 @@ class Tracer implements TracerInterface {
251
251
* @returns service - Instrumented AWS SDK v2 client
252
252
*/
253
253
public captureAWSClient < T > ( service : T ) : T {
254
- if ( this . tracingEnabled === false ) return service ;
254
+ if ( ! this . tracingEnabled ) return service ;
255
255
256
256
return this . provider . captureAWSClient ( service ) ;
257
257
}
@@ -281,7 +281,7 @@ class Tracer implements TracerInterface {
281
281
* @returns service - Instrumented AWS SDK v3 client
282
282
*/
283
283
public captureAWSv3Client < T > ( service : T ) : T {
284
- if ( this . tracingEnabled === false ) return service ;
284
+ if ( ! this . tracingEnabled ) return service ;
285
285
286
286
return this . provider . captureAWSv3Client ( service ) ;
287
287
}
@@ -322,7 +322,7 @@ class Tracer implements TracerInterface {
322
322
const originalMethod = descriptor . value ;
323
323
324
324
descriptor . value = ( ( event , context , callback ) => {
325
- if ( this . tracingEnabled === false ) {
325
+ if ( ! this . tracingEnabled ) {
326
326
return originalMethod ?. apply ( target , [ event , context , callback ] ) ;
327
327
}
328
328
@@ -389,7 +389,7 @@ class Tracer implements TracerInterface {
389
389
const originalMethod = descriptor . value ;
390
390
391
391
descriptor . value = ( ...args : unknown [ ] ) => {
392
- if ( this . tracingEnabled === false ) {
392
+ if ( ! this . tracingEnabled ) {
393
393
return originalMethod ?. apply ( target , [ ...args ] ) ;
394
394
}
395
395
@@ -417,16 +417,16 @@ class Tracer implements TracerInterface {
417
417
/**
418
418
* Retrieve the current value of `ColdStart`.
419
419
*
420
- * If Tracer has been initialized outside of the Lambda handler then the same instance
421
- * of Tracer will be reused throghout the lifecycle of that same Lambda execution environment
420
+ * If Tracer has been initialized outside the Lambda handler then the same instance
421
+ * of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
422
422
* and this method will return `false` after the first invocation.
423
423
*
424
424
* @see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
425
425
*
426
426
* @returns boolean - `true` if is cold start, otherwise `false`
427
427
*/
428
428
public static getColdStart ( ) : boolean {
429
- if ( Tracer . coldStart === true ) {
429
+ if ( Tracer . coldStart ) {
430
430
Tracer . coldStart = false ;
431
431
432
432
return true ;
@@ -498,7 +498,7 @@ class Tracer implements TracerInterface {
498
498
* @param value - Value for annotation
499
499
*/
500
500
public putAnnotation ( key : string , value : string | number | boolean ) : void {
501
- if ( this . tracingEnabled === false ) return ;
501
+ if ( ! this . tracingEnabled ) return ;
502
502
503
503
const document = this . getSegment ( ) ;
504
504
if ( document instanceof Segment ) {
@@ -528,10 +528,10 @@ class Tracer implements TracerInterface {
528
528
*
529
529
* @param key - Metadata key
530
530
* @param value - Value for metadata
531
- * @param timestamp - Namespace that metadata will lie under, if none is passed it will use the serviceName
531
+ * @param namespace - Namespace that metadata will lie under, if none is passed it will use the serviceName
532
532
*/
533
533
public putMetadata ( key : string , value : unknown , namespace ?: string | undefined ) : void {
534
- if ( this . tracingEnabled === false ) return ;
534
+ if ( ! this . tracingEnabled ) return ;
535
535
536
536
const document = this . getSegment ( ) ;
537
537
if ( document instanceof Segment ) {
@@ -608,7 +608,7 @@ class Tracer implements TracerInterface {
608
608
*
609
609
* @param serviceName - Service name to validate
610
610
*/
611
- private isValidServiceName ( serviceName ?: string ) : boolean {
611
+ private static isValidServiceName ( serviceName ?: string ) : boolean {
612
612
return typeof serviceName === 'string' && serviceName . trim ( ) . length > 0 ;
613
613
}
614
614
@@ -700,21 +700,21 @@ class Tracer implements TracerInterface {
700
700
* @param serviceName - Name of the service to use
701
701
*/
702
702
private setServiceName ( serviceName ?: string ) : void {
703
- if ( serviceName !== undefined && this . isValidServiceName ( serviceName ) ) {
703
+ if ( serviceName !== undefined && Tracer . isValidServiceName ( serviceName ) ) {
704
704
this . serviceName = serviceName ;
705
705
706
706
return ;
707
707
}
708
708
709
709
const customConfigValue = this . getCustomConfigService ( ) ?. getServiceName ( ) ;
710
- if ( customConfigValue !== undefined && this . isValidServiceName ( customConfigValue ) ) {
710
+ if ( customConfigValue !== undefined && Tracer . isValidServiceName ( customConfigValue ) ) {
711
711
this . serviceName = customConfigValue ;
712
712
713
713
return ;
714
714
}
715
715
716
716
const envVarsValue = this . getEnvVarsService ( ) ?. getServiceName ( ) ;
717
- if ( envVarsValue !== undefined && this . isValidServiceName ( envVarsValue ) ) {
717
+ if ( envVarsValue !== undefined && Tracer . isValidServiceName ( envVarsValue ) ) {
718
718
this . serviceName = envVarsValue ;
719
719
720
720
return ;
@@ -728,7 +728,7 @@ class Tracer implements TracerInterface {
728
728
* @param enabled - Whether or not tracing is enabled
729
729
*/
730
730
private setTracingEnabled ( enabled ?: boolean ) : void {
731
- if ( enabled !== undefined && enabled === false ) {
731
+ if ( enabled !== undefined && ! enabled ) {
732
732
this . tracingEnabled = enabled ;
733
733
734
734
return ;
@@ -748,7 +748,7 @@ class Tracer implements TracerInterface {
748
748
return ;
749
749
}
750
750
751
- if ( this . isLambdaSamCli ( ) || this . isLambdaExecutionEnv ( ) === false ) {
751
+ if ( this . isLambdaSamCli ( ) || ! this . isLambdaExecutionEnv ( ) ) {
752
752
this . tracingEnabled = false ;
753
753
}
754
754
}
0 commit comments