Semantic conventions for messaging client metrics

Status: Development

[!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 as a comma-separated list of category-specific values (e.g., http, databases, messaging). 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)DescriptionStabilityEntity Associations
messaging.client.operation.durationHistogramsDuration of messaging operation initiated by a producer or consumer client. [1]Development

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

Attributes:

KeyStabilityRequirement LevelValue TypeDescriptionExample Values
messaging.operation.nameDevelopmentRequiredstringThe system-specific name of the messaging operation.send; receive; ack
messaging.systemDevelopmentRequiredstringThe messaging system as identified by the client instrumentation. [1]activemq; aws.sns; aws_sqs
error.typeStableConditionally Required If and only if the messaging operation has failed.stringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-error
messaging.consumer.group.nameDevelopmentConditionally Required if applicable.stringThe name of the consumer group with which a consumer is associated. [3]my-group; indexer
messaging.destination.nameDevelopmentConditionally Required [4]stringThe message destination name [5]MyQueue; MyTopic
messaging.destination.subscription.nameDevelopmentConditionally Required if applicable.stringThe name of the destination subscription from which a message is consumed. [6]subscription-a
messaging.destination.templateDevelopmentConditionally Required if available.stringLow cardinality representation of the messaging destination name [7]/customers/{customerId}
messaging.operation.typeDevelopmentConditionally Required If applicable.stringA string identifying the type of the messaging operation. [8]create; send; receive
server.addressStableConditionally Required If available.stringServer 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
messaging.destination.partition.idDevelopmentRecommendedstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1
server.portStableRecommendedintServer port number. [10]80; 8080; 443

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

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

[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.Development
processOne or more messages are processed by a consumer.Development
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.Development
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.Development
settleOne or more messages are settled.Development

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 ActiveMQDevelopment
aws.snsAmazon Simple Notification Service (SNS)Development
aws_sqsAmazon Simple Queue Service (SQS)Development
eventgridAzure Event GridDevelopment
eventhubsAzure Event HubsDevelopment
gcp_pubsubGoogle Cloud Pub/SubDevelopment
jmsJava Message ServiceDevelopment
kafkaApache KafkaDevelopment
pulsarApache PulsarDevelopment
rabbitmqRabbitMQDevelopment
rocketmqApache RocketMQDevelopment
servicebusAzure Service BusDevelopment

Producer metrics

Metric: messaging.client.sent.messages

This metric is required.

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

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

Attributes:

KeyStabilityRequirement LevelValue TypeDescriptionExample Values
messaging.operation.nameDevelopmentRequiredstringThe system-specific name of the messaging operation.send; schedule; enqueue
messaging.systemDevelopmentRequiredstringThe messaging system as identified by the client instrumentation. [1]activemq; aws.sns; aws_sqs
error.typeStableConditionally Required If and only if the messaging operation has failed.stringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-error
messaging.destination.nameDevelopmentConditionally Required [3]stringThe message destination name [4]MyQueue; MyTopic
messaging.destination.templateDevelopmentConditionally Required if available.stringLow cardinality representation of the messaging destination name [5]/customers/{customerId}
server.addressStableConditionally Required If available.stringServer 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
messaging.destination.partition.idDevelopmentRecommendedstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1
server.portStableRecommendedintServer port number. [7]80; 8080; 443

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

[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.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 ActiveMQDevelopment
aws.snsAmazon Simple Notification Service (SNS)Development
aws_sqsAmazon Simple Queue Service (SQS)Development
eventgridAzure Event GridDevelopment
eventhubsAzure Event HubsDevelopment
gcp_pubsubGoogle Cloud Pub/SubDevelopment
jmsJava Message ServiceDevelopment
kafkaApache KafkaDevelopment
pulsarApache PulsarDevelopment
rabbitmqRabbitMQDevelopment
rocketmqApache RocketMQDevelopment
servicebusAzure Service BusDevelopment

Consumer metrics

Metric: messaging.client.consumed.messages

This metric is required.

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

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

Attributes:

KeyStabilityRequirement LevelValue TypeDescriptionExample Values
messaging.operation.nameDevelopmentRequiredstringThe system-specific name of the messaging operation.receive; peek; poll; consume
messaging.systemDevelopmentRequiredstringThe messaging system as identified by the client instrumentation. [1]activemq; aws.sns; aws_sqs
error.typeStableConditionally Required If and only if the messaging operation has failed.stringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-error
messaging.consumer.group.nameDevelopmentConditionally Required if applicable.stringThe name of the consumer group with which a consumer is associated. [3]my-group; indexer
messaging.destination.nameDevelopmentConditionally Required [4]stringThe message destination name [5]MyQueue; MyTopic
messaging.destination.subscription.nameDevelopmentConditionally Required if applicable.stringThe name of the destination subscription from which a message is consumed. [6]subscription-a
messaging.destination.templateDevelopmentConditionally Required if available.stringLow cardinality representation of the messaging destination name [7]/customers/{customerId}
server.addressStableConditionally Required If available.stringServer 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
messaging.destination.partition.idDevelopmentRecommendedstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1
server.portStableRecommendedintServer port number. [9]80; 8080; 443

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

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

[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 ActiveMQDevelopment
aws.snsAmazon Simple Notification Service (SNS)Development
aws_sqsAmazon Simple Queue Service (SQS)Development
eventgridAzure Event GridDevelopment
eventhubsAzure Event HubsDevelopment
gcp_pubsubGoogle Cloud Pub/SubDevelopment
jmsJava Message ServiceDevelopment
kafkaApache KafkaDevelopment
pulsarApache PulsarDevelopment
rabbitmqRabbitMQDevelopment
rocketmqApache RocketMQDevelopment
servicebusAzure Service BusDevelopment

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)DescriptionStabilityEntity Associations
messaging.process.durationHistogramsDuration of processing operation. [1]Development

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

Attributes:

KeyStabilityRequirement LevelValue TypeDescriptionExample Values
messaging.operation.nameDevelopmentRequiredstringThe system-specific name of the messaging operation.process; consume; handle
messaging.systemDevelopmentRequiredstringThe messaging system as identified by the client instrumentation. [1]activemq; aws.sns; aws_sqs
error.typeStableConditionally Required If and only if the messaging operation has failed.stringDescribes a class of error the operation ended with. [2]amqp:decode-error; KAFKA_STORAGE_ERROR; channel-error
messaging.consumer.group.nameDevelopmentConditionally Required if applicable.stringThe name of the consumer group with which a consumer is associated. [3]my-group; indexer
messaging.destination.nameDevelopmentConditionally Required [4]stringThe message destination name [5]MyQueue; MyTopic
messaging.destination.subscription.nameDevelopmentConditionally Required if applicable.stringThe name of the destination subscription from which a message is consumed. [6]subscription-a
messaging.destination.templateDevelopmentConditionally Required if available.stringLow cardinality representation of the messaging destination name [7]/customers/{customerId}
server.addressStableConditionally Required If available.stringServer 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
messaging.destination.partition.idDevelopmentRecommendedstringThe identifier of the partition messages are sent to or received from, unique within the messaging.destination.name.1
server.portStableRecommendedintServer port number. [9]80; 8080; 443

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

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

[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 ActiveMQDevelopment
aws.snsAmazon Simple Notification Service (SNS)Development
aws_sqsAmazon Simple Queue Service (SQS)Development
eventgridAzure Event GridDevelopment
eventhubsAzure Event HubsDevelopment
gcp_pubsubGoogle Cloud Pub/SubDevelopment
jmsJava Message ServiceDevelopment
kafkaApache KafkaDevelopment
pulsarApache PulsarDevelopment
rabbitmqRabbitMQDevelopment
rocketmqApache RocketMQDevelopment
servicebusAzure Service BusDevelopment