diff --git a/faststream/redis/opentelemetry/provider.py b/faststream/redis/opentelemetry/provider.py index 3524b04465..39927d2ffe 100644 --- a/faststream/redis/opentelemetry/provider.py +++ b/faststream/redis/opentelemetry/provider.py @@ -20,7 +20,7 @@ def get_consume_attrs_from_message( self, msg: "StreamMessage[AnyDict]", ) -> "AnyDict": - return { + attrs = { SpanAttributes.MESSAGING_SYSTEM: self.messaging_system, SpanAttributes.MESSAGING_MESSAGE_ID: msg.message_id, SpanAttributes.MESSAGING_MESSAGE_CONVERSATION_ID: msg.correlation_id, @@ -28,6 +28,11 @@ def get_consume_attrs_from_message( MESSAGING_DESTINATION_PUBLISH_NAME: msg.raw_message["channel"], } + if msg.raw_message.get("type", "").startswith("b"): + attrs[SpanAttributes.MESSAGING_BATCH_MESSAGE_COUNT] = len(msg.decoded_body) + + return attrs + def get_consume_destination_name( self, msg: "StreamMessage[AnyDict]",