@@ -84,7 +84,7 @@ interface ConsumerSpanOptions {
84
84
topic : string ;
85
85
message : KafkaMessage | undefined ;
86
86
operationType : string ;
87
- attributes ? : Attributes ;
87
+ attributes : Attributes ;
88
88
ctx ?: Context | undefined ;
89
89
link ?: Link ;
90
90
}
@@ -583,9 +583,9 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
583
583
return result ;
584
584
} )
585
585
. catch ( reason => {
586
- let errorMessage : string ;
587
- let errorType = ERROR_TYPE_VALUE_OTHER ;
588
- if ( typeof reason === 'string' ) {
586
+ let errorMessage : string | undefined ;
587
+ let errorType : string = ERROR_TYPE_VALUE_OTHER ;
588
+ if ( typeof reason === 'string' || reason === undefined ) {
589
589
errorMessage = reason ;
590
590
} else if (
591
591
typeof reason === 'object' &&
@@ -597,7 +597,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
597
597
pendingMetrics . forEach ( m => m ( errorType ) ) ;
598
598
599
599
spans . forEach ( span => {
600
- if ( errorType ) span . setAttribute ( ATTR_ERROR_TYPE , errorType ) ;
600
+ span . setAttribute ( ATTR_ERROR_TYPE , errorType ) ;
601
601
span . setStatus ( {
602
602
code : SpanStatusCode . ERROR ,
603
603
message : errorMessage ,
@@ -617,7 +617,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
617
617
operationType,
618
618
ctx,
619
619
link,
620
- attributes = { } ,
620
+ attributes,
621
621
} : ConsumerSpanOptions ) {
622
622
const operationName =
623
623
operationType === MESSAGING_OPERATION_TYPE_VALUE_RECEIVE
@@ -641,7 +641,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
641
641
? String ( message . key )
642
642
: undefined ,
643
643
[ ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE ] :
644
- message ?. key && message ? .value === null ? true : undefined ,
644
+ message ?. key && message . value === null ? true : undefined ,
645
645
[ ATTR_MESSAGING_KAFKA_OFFSET ] : message ?. offset ,
646
646
} ,
647
647
links : link ? [ link ] : [ ] ,
0 commit comments