Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging metric overrides #687

Closed
7 changes: 7 additions & 0 deletions .chloggen/553.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
change_type: enhancement

component: messaging

note: Extends generic messaging metrics for RabbitMQ, Kafka, and Azure messaging services

issues: [553]
229 changes: 221 additions & 8 deletions docs/messaging/azure-messaging.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/messaging/gcp-pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Semantic Conventions for [Google Cloud Pub/Sub](https://cloud.google.com/pub

`messaging.system` MUST be set to `"gcp_pubsub"`.

## Span attributes
## Attributes

For Google Cloud Pub/Sub, the following additional attributes are defined:
<!-- semconv messaging.gcp_pubsub(full,tag=tech-specific-gcp-pubsub) -->
Expand All @@ -31,7 +31,7 @@ flowchart LR;
direction LR
CA[Span Create A]
CB[Span Create B]
P[Span Publish A B]
P[Span Publish A B]
end
CA-. link .-P;
CB-. link .-P;
Expand Down
66 changes: 64 additions & 2 deletions docs/messaging/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ linkTitle: Kafka

<!-- toc -->

- [Span attributes](#span-attributes)
- [Attributes](#attributes)
- [Metrics](#metrics)
* [Metric: `messaging.publish.duration`](#metric-messagingpublishduration)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, didn't we had a person working on the Kakfa metrics and decided to not have them in semconv? How these will fit with those? Or are those broker and these are client ones?

* [Metric: `messaging.publish.messages`](#metric-messagingpublishmessages)
* [Metric: `messaging.receive.duration`](#metric-messagingreceiveduration)
* [Metric: `messaging.receive.messages`](#metric-messagingreceivemessages)
- [Examples](#examples)
* [Apache Kafka with Quarkus or Spring Boot Example](#apache-kafka-with-quarkus-or-spring-boot-example)

Expand All @@ -20,7 +25,7 @@ described on this page.

`messaging.system` MUST be set to `"kafka"`.

## Span attributes
## Attributes

For Apache Kafka, the following additional attributes are defined:

Expand All @@ -44,6 +49,62 @@ If an intermediary broker is present, `service.name` and `peer.service` will not

`messaging.client_id` SHOULD be set to the `client-id` of consumers, or to the `client.id` property of producers.

## Metrics

### Metric: `messaging.publish.duration`

Measures time it takes to publish message or a batch of messages to Apache Kafka including all retries.

This metric is [required][MetricRequired]

This metric follows the common [messaging.publish.duration](./messaging-metrics.md#metric-messagingpublishduration) definition.

**Notes:**

- The following attributes (with corresponding [requirement levels](#attributes)) are defined in addition to generic attributes for this metric:
* `messaging.kafka.destination.partition`

### Metric: `messaging.publish.messages`

Measures the number of published messages.

This metric is [required][MetricRequired]

This metric follows the common [messaging.publish.messages](./messaging-metrics.md#metric-messagingpublishmessages) definition.

**Notes:**

- The following attributes (with corresponding [requirement levels](#attributes)) are defined in addition to generic attributes for this metric:
* `messaging.kafka.destination.partition`

### Metric: `messaging.receive.duration`

Measures duration of consumer client call that polls messages.

This metric is [required][MetricRequired].

This metric follows the common [messaging.receive.duration](./messaging-metrics.md#metric-messagingdeliverduration) definition.

**Notes:**

- The following attributes (with corresponding [requirement levels](#attributes)) are defined in addition to generic attributes for this metric:
* `messaging.kafka.destination.partition`
* `messaging.kafka.consumer.group`

### Metric: `messaging.receive.messages`

Measures the number of received messages.

This metric is [required][MetricRequired].

This metric follows the common [messaging.receive.messages](./messaging-metrics.md#metric-messagingreceivemessages) definition.

**Notes:**

- The following attributes (with corresponding [requirement levels](#attributes)) are defined in addition to generic attributes for this metric:
* `messaging.kafka.destination.partition`
* `messaging.kafka.consumer.group`
Comment on lines +104 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to clarify with the wider semantic conventions community whether this is the way we want to extend generic metric definitions.

The approach proposed in this PR is endorsed by the messaging workgroup, because it allows telemetry consumers to utilize a single metric (for example messaging.receive.messages) to measure throughput, regardless of the messaging system used. This makes it much easier to build generic APM experiences.

For obtaining system-specific information, it is still possible to utilize the additional system-specific attributes on the metric.


## Examples

### Apache Kafka with Quarkus or Spring Boot Example
Expand Down Expand Up @@ -85,3 +146,4 @@ Process CB: | Span Rcv2 |
| `messaging.kafka.message.offset` | `"12"` | `"12"` | `"12"` | `"32"` | `"32"` |

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.26.0/specification/document-status.md
[MetricRequired]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.26.0/specification/metrics/metric-requirement-level.md#required
6 changes: 3 additions & 3 deletions docs/messaging/messaging-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ _Note: The need to report `messaging.deliver.messages` depends on the messaging
| `messaging.deliver.messages` | Counter | `{message}` | Measures the number of delivered messages. |
<!-- endsemconv -->

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.21.0/specification/document-status.md
[MetricRequired]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.21.0/specification/metrics/metric-requirement-level.md#required
[MetricOptIn]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.21.0/specification/metrics/metric-requirement-level.md#opt-in
[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.26.0/specification/document-status.md
[MetricRequired]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.26.0/specification/metrics/metric-requirement-level.md#required
[MetricOptIn]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.26.0/specification/metrics/metric-requirement-level.md#opt-in
53 changes: 52 additions & 1 deletion docs/messaging/rabbitmq.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ linkTitle: RabbitMQ

**Status**: [Experimental][DocumentStatus]

<!-- toc -->

- [Attributes](#attributes)
- [Metrics](#metrics)
* [Metric: `messaging.publish.duration`](#metric-messagingpublishduration)
* [Metric: `messaging.deliver.duration`](#metric-messagingdeliverduration)
* [Metric: `messaging.receive.duration`](#metric-messagingreceiveduration)

<!-- tocstop -->

The Semantic Conventions for [RabbitMQ](https://www.rabbitmq.com/) extend and override the [Messaging Semantic Conventions](README.md)
that describe common messaging operations attributes in addition to the Semantic Conventions
described on this page.

`messaging.system` MUST be set to `"rabbitmq"`.

## RabbitMQ attributes
## Attributes

In RabbitMQ, the destination is defined by an *exchange* and a *routing key*.
`messaging.destination.name` MUST be set to the name of the exchange. This will be an empty string if the default exchange is used.
Expand All @@ -23,4 +33,45 @@ In RabbitMQ, the destination is defined by an *exchange* and a *routing key*.
| [`messaging.rabbitmq.destination.routing_key`](../attributes-registry/messaging.md) | string | RabbitMQ message routing key. | `myKey` | Conditionally Required: If not empty. |
<!-- endsemconv -->

## Metrics

### Metric: `messaging.publish.duration`

Measures time it takes to publish a message or a batch of messages to RabbitMQ including all retries.

This metric is [required][MetricRequired]

This metric follows the common [messaging.publish.duration](./messaging-metrics.md#metric-messagingpublishduration) definition.

**Notes:**

- `messaging.publish.messages` metric is not reported: RabbitMQ doesn't support batch publish, therefore the count of published messages can be derived from the `messaging.publish.duration` metric.
- The following attributes (with corresponding [requirement levels](#attributes)) are defined in addition to generic attributes for this metric:
* `messaging.rabbitmq.destination.routing_key`

### Metric: `messaging.deliver.duration`

Measures duration of delivery callback that consumes a message.

This metric is [required][MetricRequired] when consume API is used.

This metric follows the common [messaging.receive.duration](./messaging-metrics.md#metric-messagingdeliverduration) definition.

**Notes:**

- `messaging.deliver.messages` metric is not reported: RabbitMQ doesn't support batch consumption, therefore the count of delivered messages can be derived from `messaging.deliver.duration` metric.

### Metric: `messaging.receive.duration`

Measures duration of pull call.

This metric is [required][MetricRequired] if pull API is used.

This metric follows the common [messaging.receive.duration](./messaging-metrics.md#metric-messagingdeliverduration) definition.

**Notes:**

- `messaging.receive.messages` metric is not reported: RabbitMQ doesn't support batch receive, therefore the count of received messages can be derived the from `messaging.receive.duration` metric.

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.26.0/specification/document-status.md
[MetricRequired]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.26.0/specification/metrics/metric-requirement-level.md#required
35 changes: 35 additions & 0 deletions model/trace/messaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@ groups:
- ref: messaging.servicebus.destination.subscription_name
requirement_level:
conditionally_required: If messages are received from the subscription.
- ref: server.port
requirement_level:
conditionally_required: If not default (`5672`).
examples: ["5672"]
- ref: error.type
note: >
When available, SHOULD match [AMQP error condition](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-error) or
string representation of a [management response status code](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-request-response).
Otherwise SHOULD match full name of the exception type.
examples:
["amqp:resource-limit-exceeded", "com.microsoft:message-lock-lost", "503", "System.OperationCanceledException"]
- ref: messaging.batch.message_count
- ref: messaging.destination.name
- ref: messaging.message.conversation_id
brief: Service Bus [Session Id](https://learn.microsoft.com/azure/service-bus-messaging/message-sessions)
- ref: messaging.message.id
- ref: messaging.operation
- ref: server.address

- id: messaging.eventhubs
type: attribute_group
extends: messaging
Expand All @@ -190,3 +209,19 @@ groups:
- ref: messaging.eventhubs.consumer.group
requirement_level:
conditionally_required: If not default ("$Default").
- ref: server.port
requirement_level:
conditionally_required: If not default (`5672`).
examples: ["5672"]
- ref: error.type
note: >
When available, SHOULD match [AMQP error condition](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-error) or
string representation of a [management response status code](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-request-response).
Otherwise SHOULD match full name of the exception type.
examples:
["amqp:resource-limit-exceeded", "com.microsoft:server-busy", "503", "System.OperationCanceledException"]
- ref: messaging.batch.message_count
- ref: messaging.destination.name
- ref: messaging.message.id
- ref: messaging.operation
- ref: server.address
Loading