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 the messaging semantic conventions are marked stable. Conventions include, but are not limited to, attributes, metric and span names, span kind and unit of measure.
  • SHOULD introduce an environment variable OTEL_SEMCONV_STABILITY_OPT_IN in the existing major version which is a comma-separated list of values. The list of values includes:
    • messaging - emit the new, stable messaging conventions, and stop emitting the old experimental messaging conventions that the instrumentation emitted previously.
    • messaging/dup - emit both the old and the stable messaging conventions, allowing for a seamless transition.
    • The default behavior (in the absence of one of these values) is to continue emitting whatever version of the old experimental messaging conventions the instrumentation was emitting previously.
    • Note: messaging/dup has higher precedence than messaging in case both values are present
  • SHOULD maintain (security patching at a minimum) the existing major version for at least six months after it starts emitting both sets of conventions.
  • SHOULD drop the environment variable in the next major version.
  • SHOULD emit the new, stable values for span name, span kind and similar “single” valued concepts when messaging/dup is present in the list.

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 ].

NameInstrument TypeUnit (UCUM)DescriptionStability
messaging.client.operation.durationHistogramsDuration of messaging operation initiated by a producer or consumer client. [1]Experimental

[1]: This metric SHOULD NOT be used to report processing duration - processing duration is reported in messaging.process.duration metric.

AttributeTypeDescriptionExamplesRequirement LevelStability
messaging.operation.namestringThe system-specific name of the messaging operation.send; receive; ackRequiredExperimental
messaging.systemstringThe messaging system as identified by the client instrumentation. [1]activemq; aws_sqs; eventgridRequiredExperimental
error.typestringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-errorConditionally Required If and only if the messaging operation has failed.Stable
messaging.consumer.group.namestringThe name of the consumer group with which a consumer is associated. [3]my-group; indexerConditionally Required if applicable.Experimental
messaging.destination.namestringThe message destination name [4]MyQueue; MyTopicConditionally Required [5]Experimental
messaging.destination.subscription.namestringThe name of the destination subscription from which a message is consumed. [6]subscription-aConditionally Required if applicable.Experimental
messaging.destination.templatestringLow cardinality representation of the messaging destination name [7]/customers/{customerId}Conditionally Required if available.Experimental
messaging.operation.typestringA string identifying the type of the messaging operation. [8]create; send; receiveConditionally Required If applicable.Experimental
server.addressstringServer 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.sockConditionally Required If available.Stable
messaging.destination.partition.idstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1RecommendedExperimental
server.portintServer port number. [10]80; 8080; 443RecommendedStable

[1] messaging.system: 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] error.type: 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] messaging.consumer.group.name: 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] messaging.destination.name: 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] messaging.destination.name: if and only if messaging.destination.name is known to have low cardinality. Otherwise, messaging.destination.template MAY be populated.

[6] messaging.destination.subscription.name: 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] messaging.destination.template: 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] messaging.operation.type: If a custom value is used, it MUST be of low cardinality.

[9] server.address: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.

[10] server.port: 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.

ValueDescriptionStability
_OTHERA fallback error value to be used when the instrumentation doesn’t define a custom value.Stable

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.

ValueDescriptionStability
createA 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.Experimental
processOne or more messages are processed by a consumer.Experimental
receiveOne 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.Experimental
sendOne 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.Experimental
settleOne or more messages are settled.Experimental

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.

ValueDescriptionStability
activemqApache ActiveMQExperimental
aws_sqsAmazon Simple Queue Service (SQS)Experimental
eventgridAzure Event GridExperimental
eventhubsAzure Event HubsExperimental
gcp_pubsubGoogle Cloud Pub/SubExperimental
jmsJava Message ServiceExperimental
kafkaApache KafkaExperimental
pulsarApache PulsarExperimental
rabbitmqRabbitMQExperimental
rocketmqApache RocketMQExperimental
servicebusAzure Service BusExperimental

Producer metrics

Metric: messaging.client.sent.messages

This metric is required.

NameInstrument TypeUnit (UCUM)DescriptionStability
messaging.client.sent.messagesCounter{message}Number of messages producer attempted to send to the broker. [1]Experimental

[1]: This metric MUST NOT count messages that were created but haven’t yet been sent.

AttributeTypeDescriptionExamplesRequirement LevelStability
messaging.operation.namestringThe system-specific name of the messaging operation.send; schedule; enqueueRequiredExperimental
messaging.systemstringThe messaging system as identified by the client instrumentation. [1]activemq; aws_sqs; eventgridRequiredExperimental
error.typestringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-errorConditionally Required If and only if the messaging operation has failed.Stable
messaging.destination.namestringThe message destination name [3]MyQueue; MyTopicConditionally Required [4]Experimental
messaging.destination.templatestringLow cardinality representation of the messaging destination name [5]/customers/{customerId}Conditionally Required if available.Experimental
server.addressstringServer 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.sockConditionally Required If available.Stable
messaging.destination.partition.idstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1RecommendedExperimental
server.portintServer port number. [7]80; 8080; 443RecommendedStable

[1] messaging.system: 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] error.type: 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] messaging.destination.name: 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] messaging.destination.name: if and only if messaging.destination.name is known to have low cardinality. Otherwise, messaging.destination.template MAY be populated.

[5] messaging.destination.template: 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.address: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.

[7] server.port: 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.

ValueDescriptionStability
_OTHERA fallback error value to be used when the instrumentation doesn’t define a custom value.Stable

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.

ValueDescriptionStability
activemqApache ActiveMQExperimental
aws_sqsAmazon Simple Queue Service (SQS)Experimental
eventgridAzure Event GridExperimental
eventhubsAzure Event HubsExperimental
gcp_pubsubGoogle Cloud Pub/SubExperimental
jmsJava Message ServiceExperimental
kafkaApache KafkaExperimental
pulsarApache PulsarExperimental
rabbitmqRabbitMQExperimental
rocketmqApache RocketMQExperimental
servicebusAzure Service BusExperimental

Consumer metrics

Metric: messaging.client.consumed.messages

This metric is required.

NameInstrument TypeUnit (UCUM)DescriptionStability
messaging.client.consumed.messagesCounter{message}Number of messages that were delivered to the application. [1]Experimental

[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.

AttributeTypeDescriptionExamplesRequirement LevelStability
messaging.operation.namestringThe system-specific name of the messaging operation.receive; peek; poll; consumeRequiredExperimental
messaging.systemstringThe messaging system as identified by the client instrumentation. [1]activemq; aws_sqs; eventgridRequiredExperimental
error.typestringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-errorConditionally Required If and only if the messaging operation has failed.Stable
messaging.consumer.group.namestringThe name of the consumer group with which a consumer is associated. [3]my-group; indexerConditionally Required if applicable.Experimental
messaging.destination.namestringThe message destination name [4]MyQueue; MyTopicConditionally Required [5]Experimental
messaging.destination.subscription.namestringThe name of the destination subscription from which a message is consumed. [6]subscription-aConditionally Required if applicable.Experimental
messaging.destination.templatestringLow cardinality representation of the messaging destination name [7]/customers/{customerId}Conditionally Required if available.Experimental
server.addressstringServer 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.sockConditionally Required If available.Stable
messaging.destination.partition.idstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1RecommendedExperimental
server.portintServer port number. [9]80; 8080; 443RecommendedStable

[1] messaging.system: 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] error.type: 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] messaging.consumer.group.name: 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] messaging.destination.name: 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] messaging.destination.name: if and only if messaging.destination.name is known to have low cardinality. Otherwise, messaging.destination.template MAY be populated.

[6] messaging.destination.subscription.name: 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] messaging.destination.template: 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.address: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.

[9] server.port: 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.

ValueDescriptionStability
_OTHERA fallback error value to be used when the instrumentation doesn’t define a custom value.Stable

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.

ValueDescriptionStability
activemqApache ActiveMQExperimental
aws_sqsAmazon Simple Queue Service (SQS)Experimental
eventgridAzure Event GridExperimental
eventhubsAzure Event HubsExperimental
gcp_pubsubGoogle Cloud Pub/SubExperimental
jmsJava Message ServiceExperimental
kafkaApache KafkaExperimental
pulsarApache PulsarExperimental
rabbitmqRabbitMQExperimental
rocketmqApache RocketMQExperimental
servicebusAzure Service BusExperimental

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 ].

NameInstrument TypeUnit (UCUM)DescriptionStability
messaging.process.durationHistogramsDuration of processing operation. [1]Experimental

[1]: This metric MUST be reported for operations with messaging.operation.type that matches process.

AttributeTypeDescriptionExamplesRequirement LevelStability
messaging.operation.namestringThe system-specific name of the messaging operation.process; consume; handleRequiredExperimental
messaging.systemstringThe messaging system as identified by the client instrumentation. [1]activemq; aws_sqs; eventgridRequiredExperimental
error.typestringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-errorConditionally Required If and only if the messaging operation has failed.Stable
messaging.consumer.group.namestringThe name of the consumer group with which a consumer is associated. [3]my-group; indexerConditionally Required if applicable.Experimental
messaging.destination.namestringThe message destination name [4]MyQueue; MyTopicConditionally Required [5]Experimental
messaging.destination.subscription.namestringThe name of the destination subscription from which a message is consumed. [6]subscription-aConditionally Required if applicable.Experimental
messaging.destination.templatestringLow cardinality representation of the messaging destination name [7]/customers/{customerId}Conditionally Required if available.Experimental
server.addressstringServer 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.sockConditionally Required If available.Stable
messaging.destination.partition.idstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1RecommendedExperimental
server.portintServer port number. [9]80; 8080; 443RecommendedStable

[1] messaging.system: 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] error.type: 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] messaging.consumer.group.name: 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] messaging.destination.name: 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] messaging.destination.name: if and only if messaging.destination.name is known to have low cardinality. Otherwise, messaging.destination.template MAY be populated.

[6] messaging.destination.subscription.name: 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] messaging.destination.template: 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.address: Server domain name of the broker if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name.

[9] server.port: 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.

ValueDescriptionStability
_OTHERA fallback error value to be used when the instrumentation doesn’t define a custom value.Stable

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.

ValueDescriptionStability
activemqApache ActiveMQExperimental
aws_sqsAmazon Simple Queue Service (SQS)Experimental
eventgridAzure Event GridExperimental
eventhubsAzure Event HubsExperimental
gcp_pubsubGoogle Cloud Pub/SubExperimental
jmsJava Message ServiceExperimental
kafkaApache KafkaExperimental
pulsarApache PulsarExperimental
rabbitmqRabbitMQExperimental
rocketmqApache RocketMQExperimental
servicebusAzure Service BusExperimental