spring-projects / spring-amqp

Spring AMQP - support for Spring programming model with AMQP, especially but not limited to RabbitMQ
https://spring.io/projects/spring-amqp
Apache License 2.0
808 stars 624 forks source link

OpenTelemetry with RabbitMQ add messaging.rabbitmq.destination.routing_key from the semantic convention #2814

Closed vmeunier closed 1 month ago

vmeunier commented 1 month ago

Expected Behavior

There are several fields in the semantic convention for RabbitMQ and RabbitTemplate is missing the one named messaging.rabbitmq.destination.routing_key.

Current Behavior

At the moment, in RabbitTemplate, the observationContext concatenates "exchange/routingKey" in the field messaging.destination.name

Context

If we want to be fully "OpenTelemetry compliant" then we should use all the fields we can with the information we have. IMO it is a mistake to concatenate two different strings in one, it makes the research or filtering in traces/metrics afterwards more complicated.

messaging.destination.name must be the name of the exchange messaging.rabbitmq.destination.routing_key must be the name of the routingKey

In RabbitMQ, the destination is defined by an exchange and a routing key. messaging.destination.name MUST be set to the name of the exchange. This will be an empty string if the default exchange is used.

EDIT :

We can also add somes tags for RabbitListenerObservationConvention : messaging.destination.name which will be the consumerQueue messaging.rabbitmq.message.delivery_tag the delivery tag of the message being processed

artembilan commented 1 month ago

We do not follow those conventions by default because of Status: Experimental. However additional tags to whatever we have chosen by default would not harm. In fact we had similar contribution in the past into Spring for Apache Kafka: https://github.com/spring-projects/spring-kafka/issues/2609.

So, feel free to raise respective PR and we will be more than happy to review and merge!

vmeunier commented 1 month ago

Ok, i'll try to send you a PR :)