Skip to content

Commit ac1276d

Browse files
authoredJun 20, 2024
Merge branch 'main' into messaging-span-kinds
2 parents d3d56b0 + 5d8fa26 commit ac1276d

File tree

4 files changed

+17
-56
lines changed

4 files changed

+17
-56
lines changed
 

‎.chloggen/1168.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
change_type: enhancement
2+
component: messaging
3+
note: Clarify how per-message attributes should be recorded for batch operations.
4+
issues: [ 1168 ]

‎docs/messaging/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ Technology specific semantic conventions are defined for the following messaging
2222
* [RabbitMQ](rabbitmq.md): Semantic Conventions for *RabbitMQ*.
2323
* [RocketMQ](rocketmq.md): Semantic Conventions for *Apache RocketMQ*.
2424
* [Google Cloud Pub/Sub](gcp-pubsub.md): Semantic Conventions for *Google Cloud Pub/Sub*.
25+
* [Azure Service Bus](azure-messaging.md#azure-service-bus): Semantic Conventions for *Azure Service Bus*.
26+
* [Azure Event Hubs](azure-messaging.md#azure-event-hubs): Semantic Conventions for *Azure Event Hubs*.
2527

2628
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status

‎docs/messaging/messaging-spans.md

+11-28
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@
2727
- [Consumer spans](#consumer-spans)
2828
- [Messaging attributes](#messaging-attributes)
2929
- [Consumer attributes](#consumer-attributes)
30-
- [Per-message attributes](#per-message-attributes)
31-
- [Attributes specific to certain messaging systems](#attributes-specific-to-certain-messaging-systems)
30+
- [Recording per-message attributes on batch operations](#recording-per-message-attributes-on-batch-operations)
3231
- [Examples](#examples)
3332
- [Topic with multiple consumers](#topic-with-multiple-consumers)
3433
- [Batch receiving](#batch-receiving)
3534
- [Batch publishing](#batch-publishing)
36-
- [Semantic Conventions for specific messaging technologies](#semantic-conventions-for-specific-messaging-technologies)
3735

3836
<!-- tocstop -->
3937

@@ -179,7 +177,7 @@ Messaging spans SHOULD follow the overall [guidelines for span names](https://gi
179177
The **span name** SHOULD be `{messaging.operation.name} {destination}` (see below for the exact definition of the [`{destination}`](#destination-placeholder) placeholder).
180178
<!-- markdown-link-check-enable -->
181179

182-
Semantic conventions for individual messaging systems MAY specify different span name format and then MUST document it in [semantic conventions for specific messaging technologies](#semantic-conventions-for-specific-messaging-technologies).
180+
Semantic conventions for individual messaging systems MAY specify different span name format and then MUST document it in semantic conventions for specific messaging technologies.
183181

184182
The <span id="destination-placeholder">`{destination}`</span> SHOULD describe the entity that the operation is performed against
185183
and SHOULD adhere to one of the following values, provided they are accessible:
@@ -282,14 +280,13 @@ context of the message.
282280

283281
Messaging attributes are organized into the following namespaces:
284282

285-
- `messaging.message`: Contains [per-message attributes](#per-message-attributes) that describe individual messages. Those attributes are relevant only for spans or links that represent a single message.
283+
- `messaging.message`: Contains attributes that describe individual messages.
286284
- `messaging.destination`: Contains attributes that describe the logical entity messages are published to. See [Destinations](#destinations) for more details.
287285
- `messaging.destination_publish`: Contains attributes that describe the logical entity messages were originally published to. See [Destinations](#destinations) for more details.
288286
- `messaging.batch`: Contains attributes that describe batch operations.
289287
- `messaging.consumer`: Contains [consumer attributes](#consumer-attributes) that describe the application instance that consumes a message. See [consumer](#consumer) for more details.
290288

291-
Messaging system-specific attributes MUST be defined in the corresponding `messaging.{system}` namespace
292-
as described in [Attributes specific to certain messaging systems](#attributes-specific-to-certain-messaging-systems).
289+
Messaging system-specific attributes MUST be defined in the corresponding `messaging.{system}` namespace.
293290

294291
<!-- semconv messaging(full) -->
295292
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
@@ -458,24 +455,18 @@ the broker doesn't have such notion, the original destination name SHOULD unique
458455
<!-- END AUTOGENERATED TEXT -->
459456
<!-- endsemconv -->
460457

461-
### Per-message attributes
458+
### Recording per-message attributes on batch operations
462459

463460
All messaging operations (`publish`, `receive`, `process`, or others not covered by this specification) can describe both single and/or batch of messages.
464-
Attributes in the `messaging.message` or `messaging.{system}.message` namespace describe individual messages. For single-message operations they SHOULD be set on corresponding span.
461+
Attributes in the `messaging.message` or `messaging.{system}.message` namespace apply to individual messages and typically vary between messages within the same batch.
465462

466-
For batch operations, per-message attributes are usually different and cannot be set on the corresponding span. In such cases the attributes SHOULD be set on links. See [Batch receiving](#batch-receiving) for more information on correlation using links.
463+
Some messaging systems such as Kafka or Azure Event Grid allow publishing a batch of messages to different topics in a single operation, resulting in
464+
different `messaging.destination.name` or other destination attributes within a single messaging operation.
467465

468-
Some messaging systems (e.g., Kafka, Azure EventGrid) allow publishing a single batch of messages to different topics. In such cases, the attributes in `messaging.destination` MAY be
469-
set on links. Instrumentations MAY set destination attributes on the span if all messages in the batch share the same destination.
466+
If the attribute value is the same for all messages in the batch, the instrumentation SHOULD set such attribute on the span representing the batch operation.
467+
If the attribute values vary, the instrumentation SHOULD set such attributes on links describing individual messages.
470468

471-
### Attributes specific to certain messaging systems
472-
473-
All attributes that are specific for a messaging system SHOULD be populated in `messaging.{system}` namespace. Attributes that describe a message, a destination, a consumer, or a batch of messages SHOULD be populated under the corresponding namespace:
474-
475-
* `messaging.{system}.message.*`: Describes attributes for individual messages
476-
* `messaging.{system}.destination.*`: Describes the destination a message (or a batch) are published to and received from respectively. The combination of attributes in these namespaces should uniquely identify the entity and include properties significant for this messaging system. For example, Kafka instrumentations should include partition identifier.
477-
* `messaging.{system}.consumer.*`: Describes message consumer properties
478-
* `messaging.{system}.batch.*`: Describes message batch properties
469+
See [Batch receiving](#batch-receiving) for more information on correlation using links.
479470

480471
## Examples
481472

@@ -613,12 +604,4 @@ flowchart LR;
613604
| `messaging.message.id` | `"a1"` | `"a2"` | | `"a1"` | `"a2"` |
614605
| `messaging.batch.message_count` | | | 2 | | |
615606

616-
## Semantic Conventions for specific messaging technologies
617-
618-
More specific Semantic Conventions are defined for the following messaging technologies:
619-
620-
* [Kafka](kafka.md): Semantic Conventions for *Apache Kafka*.
621-
* [RabbitMQ](rabbitmq.md): Semantic Conventions for *RabbitMQ*.
622-
* [RocketMQ](rocketmq.md): Semantic Conventions for *Apache RocketMQ*.
623-
624607
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status

‎model/trace/messaging.yaml

-28
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
11
groups:
2-
- id: messaging.message
3-
type: attribute_group
4-
brief: 'Semantic convention describing per-message attributes populated on messaging spans or links.'
5-
attributes:
6-
- ref: messaging.destination.name
7-
- ref: messaging.message.id
8-
- ref: messaging.message.conversation_id
9-
- ref: messaging.message.envelope.size
10-
- ref: messaging.message.body.size
11-
12-
- id: messaging.destination
13-
type: attribute_group
14-
brief: 'Semantic convention for attributes that describe messaging destination on broker'
15-
note: |
16-
Destination attributes should be set on publish, receive, or other spans
17-
describing messaging operations.
18-
19-
Destination attributes should be set when the messaging operation handles
20-
single messages. When the operation handles a batch of messages,
21-
the destination attributes should only be applied when the attribute value
22-
applies to all messages in the batch.
23-
In other cases, destination attributes may be set on links.
24-
attributes:
25-
- ref: messaging.destination.name
26-
- ref: messaging.destination.template
27-
- ref: messaging.destination.temporary
28-
- ref: messaging.destination.anonymous
29-
302
- id: messaging.destination_publish
313
prefix: messaging.destination_publish
324
type: attribute_group

0 commit comments

Comments
 (0)