@@ -84,7 +84,7 @@ interface ConsumerSpanOptions {
8484 topic : string ;
8585 message : KafkaMessage | undefined ;
8686 operationType : string ;
87- attributes ? : Attributes ;
87+ attributes : Attributes ;
8888 ctx ?: Context | undefined ;
8989 link ?: Link ;
9090}
@@ -583,9 +583,9 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
583583 return result ;
584584 } )
585585 . 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 ) {
589589 errorMessage = reason ;
590590 } else if (
591591 typeof reason === 'object' &&
@@ -597,7 +597,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
597597 pendingMetrics . forEach ( m => m ( errorType ) ) ;
598598
599599 spans . forEach ( span => {
600- if ( errorType ) span . setAttribute ( ATTR_ERROR_TYPE , errorType ) ;
600+ span . setAttribute ( ATTR_ERROR_TYPE , errorType ) ;
601601 span . setStatus ( {
602602 code : SpanStatusCode . ERROR ,
603603 message : errorMessage ,
@@ -617,7 +617,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
617617 operationType,
618618 ctx,
619619 link,
620- attributes = { } ,
620+ attributes,
621621 } : ConsumerSpanOptions ) {
622622 const operationName =
623623 operationType === MESSAGING_OPERATION_TYPE_VALUE_RECEIVE
@@ -641,7 +641,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<KafkaJsInstrumen
641641 ? String ( message . key )
642642 : undefined ,
643643 [ ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE ] :
644- message ?. key && message ? .value === null ? true : undefined ,
644+ message ?. key && message . value === null ? true : undefined ,
645645 [ ATTR_MESSAGING_KAFKA_OFFSET ] : message ?. offset ,
646646 } ,
647647 links : link ? [ link ] : [ ] ,
0 commit comments