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


# AWS SNSに関するセマンティック規約

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

AWS SNSに関するセマンティック規約は、このページで説明する規約に加えて、共通のAWS SDK属性を記述する一般的な[AWS SDKに関するセマンティック規約](/works/otel-specs-ja/semconv/cloud-providers/aws-sdk/)を拡張します。

## AWS SNSスパン

AWS SNSは、[一般的なメッセージングスパン](/works/otel-specs-ja/semconv/messaging/messaging-spans/#messaging-spans)を特化させたものです。

### Sendスパン（プロデューサー）

<!-- semconv span.messaging.aws.sns.send.producer -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

**Status:** ![Development](https://img.shields.io/badge/-development-blue)

このスパンは、Producerが1つ以上のメッセージをAmazon SNSに発行することを表します。

別途"Create"スパンが存在せず、"Send"スパンのコンテキストがメッセージの生成コンテキストとしてメッセージに注入される場合に、このスパンを使用します。詳細は[Producerスパン](/works/otel-specs-ja/semconv/messaging/messaging-spans/#producer-spans)を参照してください。

**Span kind** は `PRODUCER` にすべきです（SHOULD）。

**Span status** は、[エラーの記録](/works/otel-specs-ja/semconv/general/recording-errors/)の文書に従うべきです（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 | メッセージング操作のシステム固有の名前。 | `send`; `publish` |
| [`messaging.system`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | クライアント計装によって識別されたメッセージングシステム。[1] | `aws.sns` |
| [`error.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/error/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` メッセージング操作が失敗した場合に限る。 | string | 操作が終了したエラーのクラスを記述します。[2] | `AuthorizationError`; `EndpointDisabled`; `Throttled` |
| [`messaging.batch.message_count`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [3] | int | バッチ処理操作の範囲内で送信、受信、または処理されたメッセージの数。[4] | `0`; `1`; `2` |
| [`messaging.destination.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [5] | string | メッセージの宛先名[6] | `MyTopic` |
| [`messaging.destination.template`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [7] | string | メッセージング宛先名の低カーディナリティな表現[8] | `/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 | メッセージング操作の種別を識別する文字列。[9] | `send` |
| [`aws.request_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/aws/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | レスポンスヘッダー `x-amzn-requestid`、`x-amzn-request-id`、または `x-amz-request-id` として返されるAWSリクエストID。 | `79b9da39-b7ae-508a-a6bc-864b2829c622`; `C9ER4AJX75574TDJ` |
| [`aws.sns.topic.arn`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/aws/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | AWS SNSトピックのARN。Amazon SNSの[トピック](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html)は、通信チャネルとして機能する論理的なアクセスポイントです。 | `arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE` |
| [`messaging.client.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | メッセージを消費または生成するクライアントの一意な識別子。 | `client-5`; `myhost@8742@s8083jm` |
| [`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` |
| [`messaging.message.conversation_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | メッセージが属する会話を識別する会話ID。文字列として表現されます。「Correlation ID」と呼ばれることもあります。 | `MyConversationId` |
| [`messaging.message.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` スパンが単一のメッセージに対する操作を表す場合。 | string | メッセージングシステムがメッセージの識別子として使用する値。文字列として表現されます。 | `452a7c7c7c7048c2f887f61572b18fc2` |
| [`network.peer.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/network/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` このメッセージングシステムに適用可能な場合。 | string | 操作が実行されたメッセージングIntermediaryノードのピアアドレス。[10] | `10.1.2.80`; `/tmp/my.sock` |
| [`network.peer.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/network/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` `network.peer.address` が設定されている場合に限る。 | int | 操作が実行されたメッセージングIntermediaryノードのピアポート。 | `65123` |
| [`server.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | string | 利用可能であればリバースDNSルックアップなしのサーバードメイン名。それ以外の場合はIPアドレスまたはUNIXドメインソケット名。[11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` |
| [`server.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | int | サーバーのポート番号。[12] | `80`; `8080`; `443` |
| [`messaging.message.body.size`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | int | メッセージ本文のバイト数。単一メッセージの操作を表すスパンにのみ適用されます。[13] | `1439` |
| [`messaging.message.envelope.size`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | int | メッセージ本文とメタデータの合計バイト数。[14] | `2738` |

**[1] `messaging.system`:** `"aws.sns"` に設定しなければなりません（MUST）。

**[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.batch.message_count`:** スパンがメッセージのバッチに対する操作を表す場合。

**[4] `messaging.batch.message_count`:** 計装は、単一のメッセージを扱うスパンに `messaging.batch.message_count` を設定するべきではありません（SHOULD NOT）。メッセージングクライアントライブラリが同じ操作についてバッチAPIと単一メッセージAPIの両方をサポートしている場合、計装はバッチ処理APIには `messaging.batch.message_count` を使用すべきであり（SHOULD）、単一メッセージAPIには使用するべきではありません（SHOULD NOT）。

**[5] `messaging.destination.name`:** スパンが単一のメッセージに対する操作を表す場合、またはその値がバッチ内のすべてのメッセージに適用される場合。

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

**[7] `messaging.destination.template`:** 利用可能な場合。計装は、宛先名の低カーディナリティが保証されていない限り、`messaging.destination.name` をテンプレートとして使用してはなりません（MUST NOT）。

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

**[9] `messaging.operation.type`:** `send` に設定すべきです（SHOULD）。

**[10] `network.peer.address`:** 個々のメッセージングシステムに関するセマンティック規約は、`network.peer.*` 属性が適用可能かどうかを文書化すべきです（SHOULD）。ネットワークピアのアドレスとポートは、アプリケーションが個々のIntermediaryノードと直接やり取りする場合に重要です。メッセージング操作に（再試行などによって）複数のネットワーク呼び出しが関与する場合、最後に接続したノードのアドレスを使用すべきです（SHOULD）。

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

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

**[13] `messaging.message.body.size`:** 圧縮後・圧縮前のいずれのボディサイズも指す場合があります。両方のサイズがわかっている場合は、圧縮前のボディサイズを使用すべきです。

**[14] `messaging.message.envelope.size`:** 圧縮後・圧縮前のいずれのサイズも指す場合があります。両方のサイズがわかっている場合は、圧縮前のサイズを使用すべきです。

次の属性は、サンプリング判断に重要となりうるため、（いずれかが提供される場合）**スパン作成時点**で提供すべきです（SHOULD）。

* [`messaging.destination.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/)
* [`messaging.destination.partition.id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/)
* [`messaging.destination.template`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/)
* [`messaging.operation.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/)
* [`messaging.operation.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/)
* [`messaging.system`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/messaging/)
* [`server.address`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/)
* [`server.port`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/server/)

---

`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 -->

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status

