Semantic Conventions for Messaging Client Metrics
Status: Experimental
Warning Existing messaging instrumentations that are using v1.24.0 of this document (or prior) SHOULD NOT change the version of the messaging conventions that they emit by default until a transition plan to the (future) stable semantic conventions has been published. Conventions include, but are not limited to, attributes, metric and span names, and unit of measure.
Common metrics
Metric: messaging.client.operation.duration
When this metric is reported alongside a messaging span, the metric value SHOULD be the same as the corresponding span duration.
This metric is required.
This metric SHOULD be specified with
ExplicitBucketBoundaries
of [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]
.
Name | Instrument Type | Unit (UCUM) | Description | Stability |
---|---|---|---|---|
messaging.client.operation.duration | Histogram | s | Duration of messaging operation initiated by a producer or consumer client. [1] |
[1]: This metric SHOULD NOT be used to report processing duration - processing duration is reported in messaging.process.duration
metric.
Attribute | Type | Description | Examples | Requirement Level | Stability |
---|---|---|---|---|---|
messaging.operation.name | string | The system-specific name of the messaging operation. | send ; receive ; ack | Required | |
messaging.system | string | The messaging system as identified by the client instrumentation. [1] | activemq ; aws_sqs ; eventgrid | Required | |
error.type | string | Describes a class of error the operation ended with. [2] | amqp:decode-error ; KAFKA_STORAGE_ERROR ; channel-error | Conditionally Required If and only if the messaging operation has failed. | |
messaging.consumer.group.name | string | The name of the consumer group with which a consumer is associated. [3] | my-group ; indexer | Conditionally Required if applicable. | |
messaging.destination.name | string | The message destination name [4] | MyQueue ; MyTopic | Conditionally Required [5] | |
messaging.destination.subscription.name | string | The name of the destination subscription from which a message is consumed. [6] | subscription-a | Conditionally Required if applicable. | |
messaging.destination.template | string | Low cardinality representation of the messaging destination name [7] | /customers/{customerId} | Conditionally Required if available. | |
messaging.operation.type | string | A string identifying the type of the messaging operation. [8] | send ; create ; receive | Conditionally Required If applicable. | |
server.address | string | Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. [9] | example.com ; 10.1.2.80 ; /tmp/my.sock | Conditionally Required If available. | |
messaging.destination.partition.id | string | The identifier of the partition messages are sent to or received from, unique within the messaging.destination.name . | 1 | Recommended | |
server.port | int | Server port number. [10] | 80 ; 8080 ; 443 | Recommended |
[1]: The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the messaging.system
is set to kafka
based on the instrumentation’s best knowledge.
[2]: The error.type
SHOULD be predictable, and SHOULD have low cardinality.
When error.type
is set to a type (e.g., an exception type), its
canonical class name identifying the type within the artifact SHOULD be used.
Instrumentations SHOULD document the list of errors they report.
The cardinality of error.type
within one instrumentation library SHOULD be low.
Telemetry consumers that aggregate data from multiple instrumentation libraries and applications
should be prepared for error.type
to have high cardinality at query time when no
additional filters are applied.
If the operation has completed successfully, instrumentations SHOULD NOT set error.type
.
If a specific domain defines its own set of error identifiers (such as HTTP or gRPC status codes), it’s RECOMMENDED to:
- Use a domain-specific attribute
- Set
error.type
to capture all errors, regardless of whether they are defined within the domain-specific set or not.
[3]: Semantic conventions for individual messaging systems SHOULD document whether messaging.consumer.group.name
is applicable and what it means in the context of that system.
[4]: Destination name SHOULD uniquely identify a specific queue, topic or other entity within the broker. If the broker doesn’t have such notion, the destination name SHOULD uniquely identify the broker.
[5]: if and only if messaging.destination.name
is known to have low cardinality. Otherwise, messaging.destination.template
MAY be populated.
[6]: Semantic conventions for individual messaging systems SHOULD document whether messaging.destination.subscription.name
is applicable and what it means in the context of that system.
[7]: Destination names could be constructed from templates. An example would be a destination name involving a user name or product id. Although the destination name in this case is of high cardinality, the underlying template is of low cardinality and can be effectively used for grouping and aggregation.
[8]: If a custom value is used, it MUST be of low cardinality.
[9]: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.
[10]: When observed from the client side, and when communicating through an intermediary, server.port
SHOULD represent the server port behind any intermediaries, for example proxies, if it’s available.
error.type
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
_OTHER | A fallback error value to be used when the instrumentation doesn’t define a custom value. |
messaging.operation.type
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
create | A message is created. “Create” spans always refer to a single message and are used to provide a unique creation context for messages in batch sending scenarios. | |
process | One or more messages are processed by a consumer. | |
receive | One or more messages are requested by a consumer. This operation refers to pull-based scenarios, where consumers explicitly call methods of messaging SDKs to receive messages. | |
send | One or more messages are provided for sending to an intermediary. If a single message is sent, the context of the “Send” span can be used as the creation context and no “Create” span needs to be created. | |
settle | One or more messages are settled. |
messaging.system
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
activemq | Apache ActiveMQ | |
aws_sqs | Amazon Simple Queue Service (SQS) | |
eventgrid | Azure Event Grid | |
eventhubs | Azure Event Hubs | |
gcp_pubsub | Google Cloud Pub/Sub | |
jms | Java Message Service | |
kafka | Apache Kafka | |
pulsar | Apache Pulsar | |
rabbitmq | RabbitMQ | |
rocketmq | Apache RocketMQ | |
servicebus | Azure Service Bus |
Producer metrics
Metric: messaging.client.sent.messages
This metric is required.
Name | Instrument Type | Unit (UCUM) | Description | Stability |
---|---|---|---|---|
messaging.client.sent.messages | Counter | {message} | Number of messages producer attempted to send to the broker. [1] |
[1]: This metric MUST NOT count messages that were created but haven’t yet been sent.
Attribute | Type | Description | Examples | Requirement Level | Stability |
---|---|---|---|---|---|
messaging.operation.name | string | The system-specific name of the messaging operation. | send ; schedule ; enqueue | Required | |
messaging.system | string | The messaging system as identified by the client instrumentation. [1] | activemq ; aws_sqs ; eventgrid | Required | |
error.type | string | Describes a class of error the operation ended with. [2] | amqp:decode-error ; KAFKA_STORAGE_ERROR ; channel-error | Conditionally Required If and only if the messaging operation has failed. | |
messaging.destination.name | string | The message destination name [3] | MyQueue ; MyTopic | Conditionally Required [4] | |
messaging.destination.template | string | Low cardinality representation of the messaging destination name [5] | /customers/{customerId} | Conditionally Required if available. | |
server.address | string | Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. [6] | example.com ; 10.1.2.80 ; /tmp/my.sock | Conditionally Required If available. | |
messaging.destination.partition.id | string | The identifier of the partition messages are sent to or received from, unique within the messaging.destination.name . | 1 | Recommended | |
server.port | int | Server port number. [7] | 80 ; 8080 ; 443 | Recommended |
[1]: The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the messaging.system
is set to kafka
based on the instrumentation’s best knowledge.
[2]: The error.type
SHOULD be predictable, and SHOULD have low cardinality.
When error.type
is set to a type (e.g., an exception type), its
canonical class name identifying the type within the artifact SHOULD be used.
Instrumentations SHOULD document the list of errors they report.
The cardinality of error.type
within one instrumentation library SHOULD be low.
Telemetry consumers that aggregate data from multiple instrumentation libraries and applications
should be prepared for error.type
to have high cardinality at query time when no
additional filters are applied.
If the operation has completed successfully, instrumentations SHOULD NOT set error.type
.
If a specific domain defines its own set of error identifiers (such as HTTP or gRPC status codes), it’s RECOMMENDED to:
- Use a domain-specific attribute
- Set
error.type
to capture all errors, regardless of whether they are defined within the domain-specific set or not.
[3]: Destination name SHOULD uniquely identify a specific queue, topic or other entity within the broker. If the broker doesn’t have such notion, the destination name SHOULD uniquely identify the broker.
[4]: if and only if messaging.destination.name
is known to have low cardinality. Otherwise, messaging.destination.template
MAY be populated.
[5]: Destination names could be constructed from templates. An example would be a destination name involving a user name or product id. Although the destination name in this case is of high cardinality, the underlying template is of low cardinality and can be effectively used for grouping and aggregation.
[6]: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.
[7]: When observed from the client side, and when communicating through an intermediary, server.port
SHOULD represent the server port behind any intermediaries, for example proxies, if it’s available.
error.type
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
_OTHER | A fallback error value to be used when the instrumentation doesn’t define a custom value. |
messaging.system
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
activemq | Apache ActiveMQ | |
aws_sqs | Amazon Simple Queue Service (SQS) | |
eventgrid | Azure Event Grid | |
eventhubs | Azure Event Hubs | |
gcp_pubsub | Google Cloud Pub/Sub | |
jms | Java Message Service | |
kafka | Apache Kafka | |
pulsar | Apache Pulsar | |
rabbitmq | RabbitMQ | |
rocketmq | Apache RocketMQ | |
servicebus | Azure Service Bus |
Consumer metrics
Metric: messaging.client.consumed.messages
This metric is required.
Name | Instrument Type | Unit (UCUM) | Description | Stability |
---|---|---|---|---|
messaging.client.consumed.messages | Counter | {message} | Number of messages that were delivered to the application. [1] |
[1]: Records the number of messages pulled from the broker or number of messages dispatched to the application in push-based scenarios. The metric SHOULD be reported once per message delivery. For example, if receiving and processing operations are both instrumented for a single message delivery, this counter is incremented when the message is received and not reported when it is processed.
Attribute | Type | Description | Examples | Requirement Level | Stability |
---|---|---|---|---|---|
messaging.operation.name | string | The system-specific name of the messaging operation. | receive ; peek ; poll ; consume | Required | |
messaging.system | string | The messaging system as identified by the client instrumentation. [1] | activemq ; aws_sqs ; eventgrid | Required | |
error.type | string | Describes a class of error the operation ended with. [2] | amqp:decode-error ; KAFKA_STORAGE_ERROR ; channel-error | Conditionally Required If and only if the messaging operation has failed. | |
messaging.consumer.group.name | string | The name of the consumer group with which a consumer is associated. [3] | my-group ; indexer | Conditionally Required if applicable. | |
messaging.destination.name | string | The message destination name [4] | MyQueue ; MyTopic | Conditionally Required [5] | |
messaging.destination.subscription.name | string | The name of the destination subscription from which a message is consumed. [6] | subscription-a | Conditionally Required if applicable. | |
messaging.destination.template | string | Low cardinality representation of the messaging destination name [7] | /customers/{customerId} | Conditionally Required if available. | |
server.address | string | Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. [8] | example.com ; 10.1.2.80 ; /tmp/my.sock | Conditionally Required If available. | |
messaging.destination.partition.id | string | The identifier of the partition messages are sent to or received from, unique within the messaging.destination.name . | 1 | Recommended | |
server.port | int | Server port number. [9] | 80 ; 8080 ; 443 | Recommended |
[1]: The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the messaging.system
is set to kafka
based on the instrumentation’s best knowledge.
[2]: The error.type
SHOULD be predictable, and SHOULD have low cardinality.
When error.type
is set to a type (e.g., an exception type), its
canonical class name identifying the type within the artifact SHOULD be used.
Instrumentations SHOULD document the list of errors they report.
The cardinality of error.type
within one instrumentation library SHOULD be low.
Telemetry consumers that aggregate data from multiple instrumentation libraries and applications
should be prepared for error.type
to have high cardinality at query time when no
additional filters are applied.
If the operation has completed successfully, instrumentations SHOULD NOT set error.type
.
If a specific domain defines its own set of error identifiers (such as HTTP or gRPC status codes), it’s RECOMMENDED to:
- Use a domain-specific attribute
- Set
error.type
to capture all errors, regardless of whether they are defined within the domain-specific set or not.
[3]: Semantic conventions for individual messaging systems SHOULD document whether messaging.consumer.group.name
is applicable and what it means in the context of that system.
[4]: Destination name SHOULD uniquely identify a specific queue, topic or other entity within the broker. If the broker doesn’t have such notion, the destination name SHOULD uniquely identify the broker.
[5]: if and only if messaging.destination.name
is known to have low cardinality. Otherwise, messaging.destination.template
MAY be populated.
[6]: Semantic conventions for individual messaging systems SHOULD document whether messaging.destination.subscription.name
is applicable and what it means in the context of that system.
[7]: Destination names could be constructed from templates. An example would be a destination name involving a user name or product id. Although the destination name in this case is of high cardinality, the underlying template is of low cardinality and can be effectively used for grouping and aggregation.
[8]: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.
[9]: When observed from the client side, and when communicating through an intermediary, server.port
SHOULD represent the server port behind any intermediaries, for example proxies, if it’s available.
error.type
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
_OTHER | A fallback error value to be used when the instrumentation doesn’t define a custom value. |
messaging.system
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
activemq | Apache ActiveMQ | |
aws_sqs | Amazon Simple Queue Service (SQS) | |
eventgrid | Azure Event Grid | |
eventhubs | Azure Event Hubs | |
gcp_pubsub | Google Cloud Pub/Sub | |
jms | Java Message Service | |
kafka | Apache Kafka | |
pulsar | Apache Pulsar | |
rabbitmq | RabbitMQ | |
rocketmq | Apache RocketMQ | |
servicebus | Azure Service Bus |
Metric: messaging.process.duration
When this metric is reported alongside a messaging process span, the metric value SHOULD be the same as the corresponding span duration.
This metric is required for push-based message delivery and is recommended for processing operations instrumented for pull-based scenarios.
This metric SHOULD be specified with
ExplicitBucketBoundaries
of [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]
.
Name | Instrument Type | Unit (UCUM) | Description | Stability |
---|---|---|---|---|
messaging.process.duration | Histogram | s | Duration of processing operation. [1] |
[1]: This metric MUST be reported for operations with messaging.operation.type
that matches process
.
Attribute | Type | Description | Examples | Requirement Level | Stability |
---|---|---|---|---|---|
messaging.operation.name | string | The system-specific name of the messaging operation. | process ; consume ; handle | Required | |
messaging.system | string | The messaging system as identified by the client instrumentation. [1] | activemq ; aws_sqs ; eventgrid | Required | |
error.type | string | Describes a class of error the operation ended with. [2] | amqp:decode-error ; KAFKA_STORAGE_ERROR ; channel-error | Conditionally Required If and only if the messaging operation has failed. | |
messaging.consumer.group.name | string | The name of the consumer group with which a consumer is associated. [3] | my-group ; indexer | Conditionally Required if applicable. | |
messaging.destination.name | string | The message destination name [4] | MyQueue ; MyTopic | Conditionally Required [5] | |
messaging.destination.subscription.name | string | The name of the destination subscription from which a message is consumed. [6] | subscription-a | Conditionally Required if applicable. | |
messaging.destination.template | string | Low cardinality representation of the messaging destination name [7] | /customers/{customerId} | Conditionally Required if available. | |
server.address | string | Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. [8] | example.com ; 10.1.2.80 ; /tmp/my.sock | Conditionally Required If available. | |
messaging.destination.partition.id | string | The identifier of the partition messages are sent to or received from, unique within the messaging.destination.name . | 1 | Recommended | |
server.port | int | Server port number. [9] | 80 ; 8080 ; 443 | Recommended |
[1]: The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the messaging.system
is set to kafka
based on the instrumentation’s best knowledge.
[2]: The error.type
SHOULD be predictable, and SHOULD have low cardinality.
When error.type
is set to a type (e.g., an exception type), its
canonical class name identifying the type within the artifact SHOULD be used.
Instrumentations SHOULD document the list of errors they report.
The cardinality of error.type
within one instrumentation library SHOULD be low.
Telemetry consumers that aggregate data from multiple instrumentation libraries and applications
should be prepared for error.type
to have high cardinality at query time when no
additional filters are applied.
If the operation has completed successfully, instrumentations SHOULD NOT set error.type
.
If a specific domain defines its own set of error identifiers (such as HTTP or gRPC status codes), it’s RECOMMENDED to:
- Use a domain-specific attribute
- Set
error.type
to capture all errors, regardless of whether they are defined within the domain-specific set or not.
[3]: Semantic conventions for individual messaging systems SHOULD document whether messaging.consumer.group.name
is applicable and what it means in the context of that system.
[4]: Destination name SHOULD uniquely identify a specific queue, topic or other entity within the broker. If the broker doesn’t have such notion, the destination name SHOULD uniquely identify the broker.
[5]: if and only if messaging.destination.name
is known to have low cardinality. Otherwise, messaging.destination.template
MAY be populated.
[6]: Semantic conventions for individual messaging systems SHOULD document whether messaging.destination.subscription.name
is applicable and what it means in the context of that system.
[7]: Destination names could be constructed from templates. An example would be a destination name involving a user name or product id. Although the destination name in this case is of high cardinality, the underlying template is of low cardinality and can be effectively used for grouping and aggregation.
[8]: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.
[9]: When observed from the client side, and when communicating through an intermediary, server.port
SHOULD represent the server port behind any intermediaries, for example proxies, if it’s available.
error.type
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
_OTHER | A fallback error value to be used when the instrumentation doesn’t define a custom value. |
messaging.system
has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
Value | Description | Stability |
---|---|---|
activemq | Apache ActiveMQ | |
aws_sqs | Amazon Simple Queue Service (SQS) | |
eventgrid | Azure Event Grid | |
eventhubs | Azure Event Hubs | |
gcp_pubsub | Google Cloud Pub/Sub | |
jms | Java Message Service | |
kafka | Apache Kafka | |
pulsar | Apache Pulsar | |
rabbitmq | RabbitMQ | |
rocketmq | Apache RocketMQ | |
servicebus | Azure Service Bus |
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!