Asynchronous operations
In asynchronous communication via message queues (Kafka, RabbitMQ, etc.), span relationships are not modeled as parent–child; instead, span links are used. They connect spans from different traces, e.g., when multiple producers send messages and a consumer processes them in a single batch.
Naming convention
The span name has the {messaging.operation.name} {destination} format, e.g., send orders or process orders. For a topic name with high cardinality, use a template (messaging.destination.template). If the topic is unknown, use unknown. For more information, see the messaging span naming specification
Attributes
|
Attribute |
Description |
|
|
Messaging system: |
|
|
Topic or queue name: |
|
|
System operation name: |
|
|
Standardized type: |
|
|
Message ID |
|
|
Number of messages in the batch |
For a full list of attributes, see the OpenTelemetry specification for messaging spans
Examples
Multiple producers, one consumer
Producer A and Producer B each send a message to the orders Kafka topic. The consumer receives both messages in a single batch (poll orders span) and then creates an individual process orders span for each message. Span links are attached to the process spans, connecting each message back to its producer:
|
Attribute |
Producer A |
Producer B |
Consumer: receive |
Consumer: process A |
Consumer: process B |
|
Name |
|
|
|
|
|
|
Kind |
|
|
|
|
|
|
Status |
|
|
|
|
|
|
Links |
— |
— |
— |
→ |
→ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
— |
|
|
|
|
— |
— |
|
— |
— |
One producer, multiple consumers
A producer sends a message to the orders topic. Consumer X and Consumer Y from different consumer groups independently process this message. Each process span is connected to the producer's span via a span link:
|
Attribute |
Producer |
Consumer X |
Consumer Y |
|
Name |
|
|
|
|
Kind |
|
|
|
|
Status |
|
|
|
|
Links |
— |
→ |
→ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|