Skip to content

Commit ff23546

Browse files
docs(instrumentation-amqp): improve readme for sem conv versions
1 parent 612963e commit ff23546

File tree

1 file changed

+66
-18
lines changed

1 file changed

+66
-18
lines changed

packages/instrumentation-amqplib/README.md

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,72 @@ By default, the tests that connect to RabbitMQ are skipped. To make sure these t
8989

9090
## Semantic Conventions
9191

92-
This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md)
93-
94-
Attributes collected:
95-
96-
| Attribute | Short Description |
97-
| -------------------------------- | ---------------------------------------------------------------------- |
98-
| `messaging.destination` | The message destination name. |
99-
| `messaging.destination_kind` | The kind of message destination. |
100-
| `messaging.rabbitmq.routing_key` | RabbitMQ message routing key. |
101-
| `messaging.operation` | A string identifying the kind of message consumption. |
102-
| `messaging.message_id` | A value used by the messaging system as an identifier for the message. |
103-
| `messaging.conversation_id` | The ID identifying the conversation to which the message belongs. |
104-
| `messaging.protocol` | The name of the transport protocol. |
105-
| `messaging.protocol_version` | The version of the transport protocol. |
106-
| `messaging.system` | A string identifying the messaging system. |
107-
| `messaging.url` | The connection string. |
108-
| `net.peer.name` | Remote hostname or similar. |
109-
| `net.peer.port` | Remote port number. |
92+
This package supports both legacy and future stable OpenTelemetry semantic conventions for messaging systems. The behavior is controlled by the `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable.
93+
94+
**Note**: The v1.36.0+ conventions are not yet stable but will become stable in the future. This instrumentation is progressively implementing the new attributes and span names in preparation for the transition to stable conventions.
95+
96+
Configure the instrumentation using one of the following options:
97+
98+
- **Empty (default)**: Emit only legacy v1.7.0 conventions ([messaging spec](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md))
99+
- **`messaging`**: Emit only stable v1.36.0+ conventions ([messaging spec](https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/messaging/messaging-spans.md) or [RabbitMQ messaging spec](https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/messaging/rabbitmq.md))
100+
- **`messaging/dup`**: Emit both legacy and stable conventions simultaneously for migration purposes
101+
102+
### Attributes Collected
103+
104+
| v1.7.0 semconv | v1.36.0+ semconv | Description |
105+
| --------------------------------- | --------------------------------------------- | ----------- |
106+
| `messaging.protocol` | `network.protocol.name` | The name of the transport protocol (`AMQP`) |
107+
| `messaging.protocol_version` | `network.protocol.version` | The version of the transport protocol (`0.9.1`) |
108+
| `net.peer.name` | `network.peer.address` | Remote hostname or similar |
109+
| `net.peer.port` | `network.peer.port` | Remote port number |
110+
| - | `server.address` | Server hostname or similar |
111+
| - | `server.port` | Server port number |
112+
| `messaging.system` | `messaging.system` | A string identifying the messaging system (`rabbitmq`) |
113+
| `messaging.url` | Removed | The connection string (with credentials masked) |
114+
| `messaging.destination_kind` | Removed | The kind of message destination (always `topic` for RabbitMQ) |
115+
| - | `messaging.operation.type` | A string identifying the type of operation (`send`, `receive`) |
116+
| `messaging.operation` | `messaging.operation.name` | A string identifying the name of operation (`publish`, `consume`) |
117+
| `messaging.destination` | `messaging.destination.name` | The message destination name (exchange name or destination) |
118+
| `messaging.message_id` | `messaging.message.id` | A value used by the messaging system as an identifier for the message |
119+
| `messaging.conversation_id` | `messaging.message.conversation_id` | The ID identifying the conversation to which the message belongs |
120+
| - | `messaging.message.body.size` | The size of the message body in bytes |
121+
| `messaging.rabbitmq.routing_key` | `messaging.rabbitmq.destination.routing_key` | RabbitMQ message routing key |
122+
| - | `messaging.rabbitmq.message.delivery_tag` | RabbitMQ message delivery tag (consume operations only) |
123+
124+
### Span Naming Conventions
125+
126+
The instrumentation generates different span names based on the semantic convention version:
127+
128+
#### Publish Operations
129+
130+
- **Legacy**: `publish {exchange}` (or `publish <default>` for default exchange)
131+
- **Stable**: `publish {destination}` where destination follows the pattern:
132+
- `{exchange}:{routing_key}` when both are present
133+
- `{exchange}` when only exchange is present
134+
- `{routing_key}` when only routing key is present
135+
- `amq.default` when neither is present
136+
137+
#### Consume Operations
138+
139+
- **Legacy**: `{queue} process`
140+
- **Stable**: `consume {destination}` where destination follows this priority pattern:
141+
- `{exchange}:{routing_key}:{queue}` when all are present and routing_key ≠ queue
142+
- `{exchange}:{routing_key}` when all are present and routing_key = queue, or when exchange and routing_key are present
143+
- `{exchange}:{queue}` when exchange and queue are present (no routing_key)
144+
- `{routing_key}:{queue}` when routing_key and queue are present (no exchange)
145+
- `{exchange}` when only exchange is present
146+
- `{routing_key}` when only routing_key is present
147+
- `{queue}` when only queue is present
148+
- `amq.default` when none are present
149+
150+
### Migration Guide
151+
152+
When upgrading to the new semantic conventions, it is recommended to follow this migration path:
153+
154+
1. **Upgrade** `@opentelemetry/instrumentation-amqplib` to the latest version
155+
2. **Enable dual mode**: Set `OTEL_SEMCONV_STABILITY_OPT_IN=messaging/dup` to emit both old and new semantic conventions
156+
3. **Update monitoring**: Modify alerts, dashboards, metrics, and other processes to use the new semantic conventions
157+
4. **Switch to stable**: Set `OTEL_SEMCONV_STABILITY_OPT_IN=messaging` to emit only the new semantic conventions
110158

111159
## Useful links
112160

0 commit comments

Comments
 (0)