> Source: https://www.ymotongpoo.com/works/otel-specs-ja/semconv/messaging/messaging-metrics/


# メッセージングクライアントメトリクスに関するセマンティック規約

**ステータス**: [Development][DocumentStatus]

> [!IMPORTANT]
> [この文書のv1.24.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.24.0/docs/messaging/messaging-spans.md)
> 以前のバージョンを使っている既存のメッセージング計装は、次に従うべきです。
>
> * メッセージングセマンティック規約が安定版として宣言されるまで、デフォルトで発行するメッセージング規約のバージョンを変更してはなりません（SHOULD NOT）。
>   規約には、属性、メトリクス名、スパン名、スパン種別、計測単位などが含まれますが、これらに限定されません。
> * 既存のメジャーバージョンにおいて、カテゴリー別の値をカンマ区切りで列挙するリストとして環境変数 `OTEL_SEMCONV_STABILITY_OPT_IN` を導入すべきです（SHOULD）
>   （例: http、databases、messaging）。値の一覧は次のとおりです。
>   * `messaging` - 新しい安定版のメッセージング規約を発行し、それまで計装が発行していた古い実験的なメッセージング規約の発行を停止します。
>   * `messaging/dup` - 古い規約と安定版の規約の両方を発行し、円滑な移行を可能にします。
>   * これらの値がいずれも指定されていない場合のデフォルトの動作は、その計装がそれまで発行していた古い実験的なメッセージング規約のバージョンをそのまま発行し続けることです。
>   * 注記: 両方の値が指定されている場合、`messaging/dup` は `messaging` よりも優先されます。
> * 両方の規約セットを発行し始めてから少なくとも6か月間は、既存のメジャーバージョンを（少なくともセキュリティパッチの適用という形で）維持すべきです（SHOULD）。
> * 次のメジャーバージョンでは、この環境変数を削除すべきです（SHOULD）。
> * `messaging/dup` が一覧に含まれる場合、スパン名やスパン種別のような「単一の」値を持つ概念については、新しい安定版の値を発行すべきです（SHOULD）。

## 共通メトリクス

### メトリクス: `messaging.client.operation.duration`

このメトリクスがメッセージングスパンと併せて報告される場合、メトリクスの値は対応するスパンの期間と同じにすべきです（SHOULD）。

このメトリクスは[推奨][MetricRecommended]です。

このメトリクスは、[`ExplicitBucketBoundaries` advisoryパラメータ](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.59.0/specification/metrics/api.md#instrument-advisory-parameters)に `[ 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 ]` を指定すべきです（SHOULD）。

<!-- semconv metric.messaging.client.operation.duration -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
| `messaging.client.operation.duration` | Histogram | `s` | Producerまたはconsumerクライアントによって開始されたメッセージング操作の期間。[1] | ![Development](https://img.shields.io/badge/-development-blue) | |

**[1]:** このメトリクスは、処理の期間を報告するために使用するべきではありません（SHOULD NOT）。処理の期間は `messaging.process.duration` メトリクスで報告されます。

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`messaging.operation.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | メッセージング操作のシステム固有の名前。 | `send`; `receive`; `ack` |
| [`messaging.system`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | クライアント計装によって識別されたメッセージングシステム。[1] | `activemq`; `aws.sns`; `aws_sqs` |
| [`error.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/error/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` メッセージング操作が失敗した場合に限る。 | string | 操作が終了したエラーのクラスを記述します。[2] | `amqp:decode-error`; `KAFKA_STORAGE_ERROR`; `channel-error` |
| [`messaging.consumer.group.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | consumerが関連付けられているconsumerグループの名前。[3] | `my-group`; `indexer` |
| [`messaging.destination.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [4] | string | メッセージの宛先名[5] | `MyQueue`; `MyTopic` |
| [`messaging.destination.subscription.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | メッセージが消費される宛先サブスクリプションの名前。[6] | `subscription-a` |
| [`messaging.destination.template`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 利用可能な場合。 | string | メッセージング宛先名の低カーディナリティな表現[7] | `/customers/{customerId}` |
| [`messaging.operation.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | メッセージング操作の種別を識別する文字列。[8] | `create`; `send`; `receive` |
| [`server.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` 利用可能な場合。 | string | 利用可能であればリバースDNSルックアップなしのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。[9] | `example.com`; `10.1.2.80`; `/tmp/my.sock` |
| [`messaging.destination.partition.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | メッセージが送信または受信されるパーティションの識別子。`messaging.destination.name` の中で一意です。 | `1` |
| [`server.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | int | サーバーのポート番号。[10] | `80`; `8080`; `443` |

**[1] `messaging.system`:** 実際のメッセージングシステムは、クライアントに知られているものと異なる場合があります。例えば、KafkaクライアントライブラリをAzure Event Hubsとの通信に使用する場合、`messaging.system` は計装が知り得る範囲で最善の値として `kafka` に設定されます。

**[2] `error.type`:** `error.type` は予測可能であるべきであり（SHOULD）、低カーディナリティであるべきです（SHOULD）。

`error.type` を型（例えば例外の型）に設定する場合、その正規のクラス名（アーティファクト内でその型を識別するもの）を使用すべきです（SHOULD）。

記録されたエラー型が、失敗の分類に有用でないラッパーである場合、計装は代わりに内側のエラーの型を使用してもかまいません（MAY）。例えばGoでは、`%w` を使って `fmt.Errorf` で作成されたエラーは、ラッパー型が失敗の分類に役立たない場合、アンラップしてもかまいません（MAY）。

計装は、報告するエラーの一覧を文書化すべきです（SHOULD）。

1つの計装ライブラリ内での `error.type` のカーディナリティは低くあるべきですが（SHOULD）、複数の計装ライブラリやアプリケーションからのデータを集約するテレメトリーの利用者は、追加のフィルターが適用されないクエリ時には `error.type` が高カーディナリティになることを想定しておくべきです。

操作が正常に完了した場合、計装は `error.type` を設定するべきではありません（SHOULD NOT）。

特定のドメインが独自のエラー識別子の集合を定義している場合（HTTPやRPCのステータスコードなど）、次のようにすることが推奨されます（RECOMMENDED）。

- ドメイン固有の属性を使用する
- そのドメイン固有の集合の中で定義されているかどうかにかかわらず、すべてのエラーを捉えるように `error.type` を設定する

**[3] `messaging.consumer.group.name`:** 個々のメッセージングシステムに関するセマンティック規約は、`messaging.consumer.group.name` が適用可能かどうか、そしてそのシステムの文脈で何を意味するかを文書化すべきです（SHOULD）。

**[4] `messaging.destination.name`:** `messaging.destination.name` が低カーディナリティであることが分かっている場合に限る。それ以外の場合は、`messaging.destination.template` を設定してもかまいません（MAY）。

**[5] `messaging.destination.name`:** ブローカー内の特定のキュー、トピック、その他のエンティティを一意に識別すべきです（SHOULD）。ブローカーにそのような概念がない場合は、ブローカー自体を一意に識別すべきです（SHOULD）。

**[6] `messaging.destination.subscription.name`:** 個々のメッセージングシステムに関するセマンティック規約は、`messaging.destination.subscription.name` が適用可能かどうか、そしてそのシステムの文脈で何を意味するかを文書化すべきです（SHOULD）。

**[7] `messaging.destination.template`:** 宛先名はテンプレートから構築されることがあります。例えば、ユーザー名や製品IDを含む宛先名が考えられます。この場合の宛先名自体は高カーディナリティですが、その基盤となるテンプレートは低カーディナリティであり、グルーピングや集約に効果的に使用できます。

**[8] `messaging.operation.type`:** カスタム値を使用する場合、低カーディナリティでなければなりません（MUST）。

**[9] `server.address`:** 利用可能であればリバースDNSルックアップなしのブローカーのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。

**[10] `server.port`:** クライアント側から観測し、かつ中継者を経由して通信している場合、`server.port` は、利用可能であれば、その中継者（例えばプロキシ）の背後にあるサーバーポートを表すべきです（SHOULD）。

---

`error.type` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `_OTHER` | 計装がカスタム値を定義していない場合に使用されるフォールバックのエラー値。 | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |

---

`messaging.operation.type` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `create` | メッセージが作成されます。"Create"スパンは常に単一のメッセージを指し、バッチ送信のシナリオにおいてメッセージに一意な生成コンテキストを提供するために使用されます。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `process` | 1つ以上のメッセージがConsumerによって処理されます。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `receive` | 1つ以上のメッセージがConsumerによって要求されます。この操作はpullベースのシナリオを指し、Consumerがメッセージング SDKのメソッドを明示的に呼び出してメッセージを受信します。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `send` | 1つ以上のメッセージがIntermediaryへの送信のために提供されます。単一のメッセージが送信される場合、"Send"スパンのコンテキストを生成コンテキストとして使用でき、"Create"スパンを作成する必要はありません。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `settle` | 1つ以上のメッセージが決着されます。 | ![Development](https://img.shields.io/badge/-development-blue) |

---

`messaging.system` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `activemq` | Apache ActiveMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws.sns` | Amazon Simple Notification Service（SNS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws_sqs` | Amazon Simple Queue Service（SQS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventgrid` | Azure Event Grid | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventhubs` | Azure Event Hubs | ![Development](https://img.shields.io/badge/-development-blue) |
| `gcp_pubsub` | Google Cloud Pub/Sub | ![Development](https://img.shields.io/badge/-development-blue) |
| `jms` | Java Message Service | ![Development](https://img.shields.io/badge/-development-blue) |
| `kafka` | Apache Kafka | ![Development](https://img.shields.io/badge/-development-blue) |
| `pulsar` | Apache Pulsar | ![Development](https://img.shields.io/badge/-development-blue) |
| `rabbitmq` | RabbitMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `rocketmq` | Apache RocketMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `servicebus` | Azure Service Bus | ![Development](https://img.shields.io/badge/-development-blue) |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## Producerメトリクス

### メトリクス: `messaging.client.sent.messages`

このメトリクスは[推奨][MetricRecommended]です。

<!-- semconv metric.messaging.client.sent.messages -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
| `messaging.client.sent.messages` | Counter | `{message}` | Producerがブローカーへの送信を試みたメッセージの数。[1] | ![Development](https://img.shields.io/badge/-development-blue) | |

**[1]:** このメトリクスは、作成されたがまだ送信されていないメッセージを数えてはなりません（MUST NOT）。

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`messaging.operation.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | メッセージング操作のシステム固有の名前。 | `send`; `schedule`; `enqueue` |
| [`messaging.system`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | クライアント計装によって識別されたメッセージングシステム。[1] | `activemq`; `aws.sns`; `aws_sqs` |
| [`error.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/error/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` メッセージング操作が失敗した場合に限る。 | string | 操作が終了したエラーのクラスを記述します。[2] | `amqp:decode-error`; `KAFKA_STORAGE_ERROR`; `channel-error` |
| [`messaging.destination.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [3] | string | メッセージの宛先名[4] | `MyQueue`; `MyTopic` |
| [`messaging.destination.template`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 利用可能な場合。 | string | メッセージング宛先名の低カーディナリティな表現[5] | `/customers/{customerId}` |
| [`server.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` 利用可能な場合。 | string | 利用可能であればリバースDNSルックアップなしのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。[6] | `example.com`; `10.1.2.80`; `/tmp/my.sock` |
| [`messaging.destination.partition.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | メッセージが送信または受信されるパーティションの識別子。`messaging.destination.name` の中で一意です。 | `1` |
| [`server.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | int | サーバーのポート番号。[7] | `80`; `8080`; `443` |

**[1] `messaging.system`:** 実際のメッセージングシステムは、クライアントに知られているものと異なる場合があります。例えば、KafkaクライアントライブラリをAzure Event Hubsとの通信に使用する場合、`messaging.system` は計装が知り得る範囲で最善の値として `kafka` に設定されます。

**[2] `error.type`:** `error.type` は予測可能であるべきであり（SHOULD）、低カーディナリティであるべきです（SHOULD）。

`error.type` を型（例えば例外の型）に設定する場合、その正規のクラス名（アーティファクト内でその型を識別するもの）を使用すべきです（SHOULD）。

記録されたエラー型が、失敗の分類に有用でないラッパーである場合、計装は代わりに内側のエラーの型を使用してもかまいません（MAY）。例えばGoでは、`%w` を使って `fmt.Errorf` で作成されたエラーは、ラッパー型が失敗の分類に役立たない場合、アンラップしてもかまいません（MAY）。

計装は、報告するエラーの一覧を文書化すべきです（SHOULD）。

1つの計装ライブラリ内での `error.type` のカーディナリティは低くあるべきですが（SHOULD）、複数の計装ライブラリやアプリケーションからのデータを集約するテレメトリーの利用者は、追加のフィルターが適用されないクエリ時には `error.type` が高カーディナリティになることを想定しておくべきです。

操作が正常に完了した場合、計装は `error.type` を設定するべきではありません（SHOULD NOT）。

特定のドメインが独自のエラー識別子の集合を定義している場合（HTTPやRPCのステータスコードなど）、次のようにすることが推奨されます（RECOMMENDED）。

- ドメイン固有の属性を使用する
- そのドメイン固有の集合の中で定義されているかどうかにかかわらず、すべてのエラーを捉えるように `error.type` を設定する

**[3] `messaging.destination.name`:** `messaging.destination.name` が低カーディナリティであることが分かっている場合に限る。それ以外の場合は、`messaging.destination.template` を設定してもかまいません（MAY）。

**[4] `messaging.destination.name`:** ブローカー内の特定のキュー、トピック、その他のエンティティを一意に識別すべきです（SHOULD）。ブローカーにそのような概念がない場合は、ブローカー自体を一意に識別すべきです（SHOULD）。

**[5] `messaging.destination.template`:** 宛先名はテンプレートから構築されることがあります。例えば、ユーザー名や製品IDを含む宛先名が考えられます。この場合の宛先名自体は高カーディナリティですが、その基盤となるテンプレートは低カーディナリティであり、グルーピングや集約に効果的に使用できます。

**[6] `server.address`:** 利用可能であればリバースDNSルックアップなしのブローカーのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。

**[7] `server.port`:** クライアント側から観測し、かつ中継者を経由して通信している場合、`server.port` は、利用可能であれば、その中継者（例えばプロキシ）の背後にあるサーバーポートを表すべきです（SHOULD）。

---

`error.type` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `_OTHER` | 計装がカスタム値を定義していない場合に使用されるフォールバックのエラー値。 | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |

---

`messaging.system` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `activemq` | Apache ActiveMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws.sns` | Amazon Simple Notification Service（SNS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws_sqs` | Amazon Simple Queue Service（SQS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventgrid` | Azure Event Grid | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventhubs` | Azure Event Hubs | ![Development](https://img.shields.io/badge/-development-blue) |
| `gcp_pubsub` | Google Cloud Pub/Sub | ![Development](https://img.shields.io/badge/-development-blue) |
| `jms` | Java Message Service | ![Development](https://img.shields.io/badge/-development-blue) |
| `kafka` | Apache Kafka | ![Development](https://img.shields.io/badge/-development-blue) |
| `pulsar` | Apache Pulsar | ![Development](https://img.shields.io/badge/-development-blue) |
| `rabbitmq` | RabbitMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `rocketmq` | Apache RocketMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `servicebus` | Azure Service Bus | ![Development](https://img.shields.io/badge/-development-blue) |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## Consumerメトリクス

### メトリクス: `messaging.client.consumed.messages`

このメトリクスは[推奨][MetricRecommended]です。

<!-- semconv metric.messaging.client.consumed.messages -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
| `messaging.client.consumed.messages` | Counter | `{message}` | アプリケーションに配信されたメッセージの数。[1] | ![Development](https://img.shields.io/badge/-development-blue) | |

**[1]:** ブローカーから取得されたメッセージの数、またはpushベースのシナリオでアプリケーションにディスパッチされたメッセージの数を記録します。
このメトリクスはメッセージの配信ごとに1回報告すべきです（SHOULD）。例えば、単一のメッセージ配信について受信操作と処理操作の両方が計装されている場合、このカウンターはメッセージが受信された時点でインクリメントされ、処理された時点では報告されません。

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`messaging.operation.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | メッセージング操作のシステム固有の名前。 | `receive`; `peek`; `poll`; `consume` |
| [`messaging.system`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | クライアント計装によって識別されたメッセージングシステム。[1] | `activemq`; `aws.sns`; `aws_sqs` |
| [`error.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/error/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` メッセージング操作が失敗した場合に限る。 | string | 操作が終了したエラーのクラスを記述します。[2] | `amqp:decode-error`; `KAFKA_STORAGE_ERROR`; `channel-error` |
| [`messaging.consumer.group.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | consumerが関連付けられているconsumerグループの名前。[3] | `my-group`; `indexer` |
| [`messaging.destination.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [4] | string | メッセージの宛先名[5] | `MyQueue`; `MyTopic` |
| [`messaging.destination.subscription.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | メッセージが消費される宛先サブスクリプションの名前。[6] | `subscription-a` |
| [`messaging.destination.template`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 利用可能な場合。 | string | メッセージング宛先名の低カーディナリティな表現[7] | `/customers/{customerId}` |
| [`server.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` 利用可能な場合。 | string | 利用可能であればリバースDNSルックアップなしのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。[8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` |
| [`messaging.destination.partition.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | メッセージが送信または受信されるパーティションの識別子。`messaging.destination.name` の中で一意です。 | `1` |
| [`server.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | int | サーバーのポート番号。[9] | `80`; `8080`; `443` |

**[1] `messaging.system`:** 実際のメッセージングシステムは、クライアントに知られているものと異なる場合があります。例えば、KafkaクライアントライブラリをAzure Event Hubsとの通信に使用する場合、`messaging.system` は計装が知り得る範囲で最善の値として `kafka` に設定されます。

**[2] `error.type`:** `error.type` は予測可能であるべきであり（SHOULD）、低カーディナリティであるべきです（SHOULD）。

`error.type` を型（例えば例外の型）に設定する場合、その正規のクラス名（アーティファクト内でその型を識別するもの）を使用すべきです（SHOULD）。

記録されたエラー型が、失敗の分類に有用でないラッパーである場合、計装は代わりに内側のエラーの型を使用してもかまいません（MAY）。例えばGoでは、`%w` を使って `fmt.Errorf` で作成されたエラーは、ラッパー型が失敗の分類に役立たない場合、アンラップしてもかまいません（MAY）。

計装は、報告するエラーの一覧を文書化すべきです（SHOULD）。

1つの計装ライブラリ内での `error.type` のカーディナリティは低くあるべきですが（SHOULD）、複数の計装ライブラリやアプリケーションからのデータを集約するテレメトリーの利用者は、追加のフィルターが適用されないクエリ時には `error.type` が高カーディナリティになることを想定しておくべきです。

操作が正常に完了した場合、計装は `error.type` を設定するべきではありません（SHOULD NOT）。

特定のドメインが独自のエラー識別子の集合を定義している場合（HTTPやRPCのステータスコードなど）、次のようにすることが推奨されます（RECOMMENDED）。

- ドメイン固有の属性を使用する
- そのドメイン固有の集合の中で定義されているかどうかにかかわらず、すべてのエラーを捉えるように `error.type` を設定する

**[3] `messaging.consumer.group.name`:** 個々のメッセージングシステムに関するセマンティック規約は、`messaging.consumer.group.name` が適用可能かどうか、そしてそのシステムの文脈で何を意味するかを文書化すべきです（SHOULD）。

**[4] `messaging.destination.name`:** `messaging.destination.name` が低カーディナリティであることが分かっている場合に限る。それ以外の場合は、`messaging.destination.template` を設定してもかまいません（MAY）。

**[5] `messaging.destination.name`:** ブローカー内の特定のキュー、トピック、その他のエンティティを一意に識別すべきです（SHOULD）。ブローカーにそのような概念がない場合は、ブローカー自体を一意に識別すべきです（SHOULD）。

**[6] `messaging.destination.subscription.name`:** 個々のメッセージングシステムに関するセマンティック規約は、`messaging.destination.subscription.name` が適用可能かどうか、そしてそのシステムの文脈で何を意味するかを文書化すべきです（SHOULD）。

**[7] `messaging.destination.template`:** 宛先名はテンプレートから構築されることがあります。例えば、ユーザー名や製品IDを含む宛先名が考えられます。この場合の宛先名自体は高カーディナリティですが、その基盤となるテンプレートは低カーディナリティであり、グルーピングや集約に効果的に使用できます。

**[8] `server.address`:** 利用可能であればリバースDNSルックアップなしのブローカーのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。

**[9] `server.port`:** クライアント側から観測し、かつ中継者を経由して通信している場合、`server.port` は、利用可能であれば、その中継者（例えばプロキシ）の背後にあるサーバーポートを表すべきです（SHOULD）。

---

`error.type` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `_OTHER` | 計装がカスタム値を定義していない場合に使用されるフォールバックのエラー値。 | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |

---

`messaging.system` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `activemq` | Apache ActiveMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws.sns` | Amazon Simple Notification Service（SNS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws_sqs` | Amazon Simple Queue Service（SQS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventgrid` | Azure Event Grid | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventhubs` | Azure Event Hubs | ![Development](https://img.shields.io/badge/-development-blue) |
| `gcp_pubsub` | Google Cloud Pub/Sub | ![Development](https://img.shields.io/badge/-development-blue) |
| `jms` | Java Message Service | ![Development](https://img.shields.io/badge/-development-blue) |
| `kafka` | Apache Kafka | ![Development](https://img.shields.io/badge/-development-blue) |
| `pulsar` | Apache Pulsar | ![Development](https://img.shields.io/badge/-development-blue) |
| `rabbitmq` | RabbitMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `rocketmq` | Apache RocketMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `servicebus` | Azure Service Bus | ![Development](https://img.shields.io/badge/-development-blue) |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

### メトリクス: `messaging.process.duration`

このメトリクスがメッセージング処理スパンと併せて報告される場合、メトリクスの値は対応するスパンの期間と同じにすべきです（SHOULD）。

このメトリクスは、push型のメッセージ配信、およびpullベースのシナリオで計装された処理操作の両方について[推奨][MetricRecommended]です。

このメトリクスは、[`ExplicitBucketBoundaries` advisoryパラメータ](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.59.0/specification/metrics/api.md#instrument-advisory-parameters)に `[ 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 ]` を指定すべきです（SHOULD）。

<!-- semconv metric.messaging.process.duration -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
| `messaging.process.duration` | Histogram | `s` | 処理操作の期間。[1] | ![Development](https://img.shields.io/badge/-development-blue) | |

**[1]:** このメトリクスは、`messaging.operation.type` が `process` と一致する操作について報告しなければなりません（MUST）。

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`messaging.operation.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | メッセージング操作のシステム固有の名前。 | `process`; `consume`; `handle` |
| [`messaging.system`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | クライアント計装によって識別されたメッセージングシステム。[1] | `activemq`; `aws.sns`; `aws_sqs` |
| [`error.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/error/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` メッセージング操作が失敗した場合に限る。 | string | 操作が終了したエラーのクラスを記述します。[2] | `amqp:decode-error`; `KAFKA_STORAGE_ERROR`; `channel-error` |
| [`messaging.consumer.group.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | consumerが関連付けられているconsumerグループの名前。[3] | `my-group`; `indexer` |
| [`messaging.destination.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [4] | string | メッセージの宛先名[5] | `MyQueue`; `MyTopic` |
| [`messaging.destination.subscription.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 適用可能な場合。 | string | メッセージが消費される宛先サブスクリプションの名前。[6] | `subscription-a` |
| [`messaging.destination.template`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` 利用可能な場合。 | string | メッセージング宛先名の低カーディナリティな表現[7] | `/customers/{customerId}` |
| [`server.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` 利用可能な場合。 | string | 利用可能であればリバースDNSルックアップなしのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。[8] | `example.com`; `10.1.2.80`; `/tmp/my.sock` |
| [`messaging.destination.partition.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | メッセージが送信または受信されるパーティションの識別子。`messaging.destination.name` の中で一意です。 | `1` |
| [`server.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | int | サーバーのポート番号。[9] | `80`; `8080`; `443` |

**[1] `messaging.system`:** 実際のメッセージングシステムは、クライアントに知られているものと異なる場合があります。例えば、KafkaクライアントライブラリをAzure Event Hubsとの通信に使用する場合、`messaging.system` は計装が知り得る範囲で最善の値として `kafka` に設定されます。

**[2] `error.type`:** `error.type` は予測可能であるべきであり（SHOULD）、低カーディナリティであるべきです（SHOULD）。

`error.type` を型（例えば例外の型）に設定する場合、その正規のクラス名（アーティファクト内でその型を識別するもの）を使用すべきです（SHOULD）。

記録されたエラー型が、失敗の分類に有用でないラッパーである場合、計装は代わりに内側のエラーの型を使用してもかまいません（MAY）。例えばGoでは、`%w` を使って `fmt.Errorf` で作成されたエラーは、ラッパー型が失敗の分類に役立たない場合、アンラップしてもかまいません（MAY）。

計装は、報告するエラーの一覧を文書化すべきです（SHOULD）。

1つの計装ライブラリ内での `error.type` のカーディナリティは低くあるべきですが（SHOULD）、複数の計装ライブラリやアプリケーションからのデータを集約するテレメトリーの利用者は、追加のフィルターが適用されないクエリ時には `error.type` が高カーディナリティになることを想定しておくべきです。

操作が正常に完了した場合、計装は `error.type` を設定するべきではありません（SHOULD NOT）。

特定のドメインが独自のエラー識別子の集合を定義している場合（HTTPやRPCのステータスコードなど）、次のようにすることが推奨されます（RECOMMENDED）。

- ドメイン固有の属性を使用する
- そのドメイン固有の集合の中で定義されているかどうかにかかわらず、すべてのエラーを捉えるように `error.type` を設定する

**[3] `messaging.consumer.group.name`:** 個々のメッセージングシステムに関するセマンティック規約は、`messaging.consumer.group.name` が適用可能かどうか、そしてそのシステムの文脈で何を意味するかを文書化すべきです（SHOULD）。

**[4] `messaging.destination.name`:** `messaging.destination.name` が低カーディナリティであることが分かっている場合に限る。それ以外の場合は、`messaging.destination.template` を設定してもかまいません（MAY）。

**[5] `messaging.destination.name`:** ブローカー内の特定のキュー、トピック、その他のエンティティを一意に識別すべきです（SHOULD）。ブローカーにそのような概念がない場合は、ブローカー自体を一意に識別すべきです（SHOULD）。

**[6] `messaging.destination.subscription.name`:** 個々のメッセージングシステムに関するセマンティック規約は、`messaging.destination.subscription.name` が適用可能かどうか、そしてそのシステムの文脈で何を意味するかを文書化すべきです（SHOULD）。

**[7] `messaging.destination.template`:** 宛先名はテンプレートから構築されることがあります。例えば、ユーザー名や製品IDを含む宛先名が考えられます。この場合の宛先名自体は高カーディナリティですが、その基盤となるテンプレートは低カーディナリティであり、グルーピングや集約に効果的に使用できます。

**[8] `server.address`:** 利用可能であればリバースDNSルックアップなしのブローカーのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。

**[9] `server.port`:** クライアント側から観測し、かつ中継者を経由して通信している場合、`server.port` は、利用可能であれば、その中継者（例えばプロキシ）の背後にあるサーバーポートを表すべきです（SHOULD）。

---

`error.type` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `_OTHER` | 計装がカスタム値を定義していない場合に使用されるフォールバックのエラー値。 | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |

---

`messaging.system` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `activemq` | Apache ActiveMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws.sns` | Amazon Simple Notification Service（SNS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws_sqs` | Amazon Simple Queue Service（SQS） | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventgrid` | Azure Event Grid | ![Development](https://img.shields.io/badge/-development-blue) |
| `eventhubs` | Azure Event Hubs | ![Development](https://img.shields.io/badge/-development-blue) |
| `gcp_pubsub` | Google Cloud Pub/Sub | ![Development](https://img.shields.io/badge/-development-blue) |
| `jms` | Java Message Service | ![Development](https://img.shields.io/badge/-development-blue) |
| `kafka` | Apache Kafka | ![Development](https://img.shields.io/badge/-development-blue) |
| `pulsar` | Apache Pulsar | ![Development](https://img.shields.io/badge/-development-blue) |
| `rabbitmq` | RabbitMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `rocketmq` | Apache RocketMQ | ![Development](https://img.shields.io/badge/-development-blue) |
| `servicebus` | Azure Service Bus | ![Development](https://img.shields.io/badge/-development-blue) |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
[MetricRecommended]: /works/otel-specs-ja/semconv/general/signal-requirement-level/#recommended

