> Source: https://www.ymotongpoo.com/works/otel-specs-ja/semconv/faas/faas-spans/


# FaaSスパンに関するセマンティック規約

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

この文書では、サーバーのプロビジョニングや管理を伴わずに実行される関数のインスタンス（サーバーレス関数、Function as a Service（FaaS）とも呼ばれます）をスパンで記述する方法を定義します。

[AWS Lambdaを計装するための追加の指示](/works/otel-specs-ja/semconv/faas/aws-lambda/)も参照してください。

## 全般的な属性

スパンの`name`は、実行される関数の名前に設定するべきです（should）。`faas.trigger`属性の値によって、追加の属性を設定しなければなりません（MUST）。たとえば、`http`トリガーは[HTTPサーバーのセマンティック規約](/works/otel-specs-ja/semconv/http/http-spans/#httpサーバースパン)に従うべきです（SHOULD）。詳細は、[Function Trigger Type](#関数トリガーの種類)の節を参照してください。

この規約に従ったスパンが生成される場合、[リソースのセマンティック規約](https://opentelemetry.io/docs/specs/semconv/resource/faas/)に従った`faas`型のリソースが存在しなければなりません（MUST）。

### 関数名

関数の名前を記録できる場所は2つあります。スパン名と、[`faas.name`リソース属性](https://opentelemetry.io/docs/specs/semconv/resource/faas/)です。

`faas.name`属性が存在する場合、その属性は関数名を含むことが保証されています。これは、まさにその目的のためにセマンティック規約で厳密に定義されているためです。また、スパン名にも関数名が含まれる可能性が非常に高いです（スパンの表示目的など）が、これは保証されていません（より弱い「SHOULD」要件であるため）。この保証を必要とする利用者は、`faas.name`属性を情報源として使用できます。

### 呼び出し（invocation）とインスタンス（instance）の違い

パフォーマンス上の理由（[AWS Lambda]や[Azure Functions]など）から、FaaSプロバイダーは、複数のリクエストを処理するために使われる関数の単一インスタンスに対して、1つの実行環境を割り当てます。
開発者は、この事実を利用して、異なる関数呼び出しの間でコストの高いリソース計算をキャッシュすることで、**コールドスタート**の問題を解決しています。
さらに、FaaSプロバイダーはこの挙動を推奨しています（[Google Functions]など）。
`faas.instance`リソース属性は、同じ実行環境に属する関数呼び出しを関連付けるために設定されてもかまいません（MAY）。
スパン属性`faas.invocation_id`は、次の点で[リソース属性][FaaS resource attributes]の`faas.instance`とは異なります。

- `faas.invocation_id`は、その関数の現在の呼び出しのIDを指します。
- `faas.instance`は、その関数の実行環境のIDを指します。

[AWS Lambda]: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
[Azure Functions]: https://learn.microsoft.com/azure/azure-functions/manage-connections#reuse-client-instances
[Google Functions]: https://cloud.google.com/functions/docs/concepts/execution-environment

## 受信側の呼び出し

この節では、FaaSインスタンス自身が報告する受信側のFaaS呼び出しについて説明します。

### 受信側のFaaSスパン属性

<!-- semconv span.faas.server -->
<!-- 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)

このスパンは、FaaS呼び出しのサーバー側（受信側）を表します。

**スパン種別**は`SERVER`であるべきです（SHOULD）。

**スパンステータス**は[エラーの記録](/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 |
| --- | --- | --- | --- | --- | --- |
| [`faas.trigger`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | この関数呼び出しの原因となったトリガーの種類。 | `datasource`; `http`; `pubsub` |
| [`cloud.resource_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/cloud/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 監視対象のクラウドリソースのクラウドプロバイダー固有のネイティブ識別子（AWSの[ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)、Azureの[完全修飾リソースID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id)、GCPの[完全なリソース名](https://google.aip.dev/122#full-resource-names)など）[1] | `arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function`; `//run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID`; `/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>` |
| [`faas.coldstart`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | boolean | サーバーレス関数が初めて実行される場合（コールドスタート）にtrueとなるブール値。 | |
| [`faas.invocation_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 現在の関数呼び出しの呼び出しID。 | `af9d5aa4-a685-4c5f-a22b-444f80b3cc28` |

**[1] `cloud.resource_id`:** 一部のクラウドプロバイダーでは、起動時に完全なIDを判定できない場合があるため、代わりにスパン属性として`cloud.resource_id`を設定する必要があるかもしれません。

`cloud.resource_id`に使用する正確な値は、クラウドプロバイダーによって異なります。
この属性を設定し、かつ次の条件が該当する場合、次のよく知られた定義を使用しなければなりません（MUST）。

- **AWS Lambda:** 関数の[ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)。「invoked ARN」をそのまま使わず、[エイリアスのsuffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)を解決済みの関数バージョンに置き換えるよう注意してください。同一のランタイムインスタンスが複数の異なるエイリアスで呼び出し可能な場合があるためです。
- **GCP:** [リソースのURI](https://cloud.google.com/iam/docs/full-resource-names)。
- **Azure:** 呼び出された関数の[完全修飾リソースID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id)（関数アプリ*ではありません*）。形式は`/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`です。Azureの関数アプリは通常同じTracerProviderを共有する複数の関数をホストできるため、スパン属性を使わなければなりません（MUST）。

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `datasource` | データベースやファイルシステムの読み書きなど、データソースの操作に対する応答。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `http` | 受信したHTTPリクエストへの応答を提供する。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `other` | 他のいずれにも当てはまらない場合。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `pubsub` | メッセージングシステムにメッセージが送信されたときに実行されるよう設定された関数。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `timer` | 定期的に実行されるようスケジュールされた関数。 | ![Development](https://img.shields.io/badge/-development-blue) |

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

### 受信側のFaaSスパン属性としてのリソース属性

上記に列挙した属性に加えて、[FaaS](https://opentelemetry.io/docs/specs/semconv/resource/faas/)や[cloud](https://opentelemetry.io/docs/specs/semconv/resource/cloud/)のリソース属性は、受信側のFaaS呼び出しスパンにスパン属性として代わりに設定されてもかまいません（MAY）。一部のFaaS環境では、リソース属性に必要な情報の一部が、呼び出しのコンテキスト内（「requestコンテキスト」引数の一部など）でしか容易に入手できず、リソース情報を確認するための別のAPI呼び出しが可能な場合でも、コールドスタート時間の観点から法外なコストになる可能性があります。
AWSにおける`cloud.resource_id`属性と`cloud.account.id`属性は、その一例です。
原則として、上記の考慮事項は、上記の基準（追加の作業なしには容易に入手できず、その作業がコストの高いものになりうる）を満たすすべてのリソース属性に当てはまります。

## 送信側の呼び出し

この節では、FaaSインスタンスを呼び出すクライアントが報告する送信側のFaaS呼び出しについて説明します。

<!-- semconv span.faas.client -->
<!-- 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)

このスパンは、FaaSサービスへの送信呼び出しを表します。

以下に列挙する属性についてクライアントが報告する値は、呼び出されたFaaSインスタンスが計装されている場合、そのインスタンス自身について報告する対応する[FaaSリソース属性][FaaS resource attributes]や[クラウドリソース属性][Cloud resource attributes]と等しいべきです（SHOULD）。

**スパン種別**は`CLIENT`であるべきです（SHOULD）。

**スパンステータス**は[エラーの記録](/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 |
| --- | --- | --- | --- | --- | --- |
| [`faas.invoked_name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | 呼び出された関数の名前。[1] | `my-function` |
| [`faas.invoked_provider`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | 呼び出された関数のクラウドプロバイダー。[2] | `alibaba_cloud`; `aws`; `azure` |
| [`faas.invoked_region`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` [3] | string | 呼び出された関数のクラウドリージョン。[4] | `eu-central-1` |

**[1] `faas.invoked_name`:** 呼び出された関数の`faas.name`リソース属性と等しいべきです（SHOULD）。

**[2] `faas.invoked_provider`:** 呼び出された関数の`cloud.provider`リソース属性と等しいべきです（SHOULD）。

**[3] `faas.invoked_region`:** AWSやGCPなど一部のクラウドプロバイダーでは、関数がホストされているリージョンは、その関数を一意に識別するために欠かせない情報であり、エンドポイントの一部でもあります。呼び出し先のエンドポイントの一部であるため、リージョンはクライアント側で常に判明しています。この場合、`faas.invoked_region`はそれに応じて設定されなければなりません（MUST）。リージョンがクライアント側で不明であるか、呼び出された関数を識別するために不要な場合、`faas.invoked_region`の設定は任意です。

**[4] `faas.invoked_region`:** 呼び出された関数の`cloud.region`リソース属性と等しいべきです（SHOULD）。

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `alibaba_cloud` | Alibaba Cloud | ![Development](https://img.shields.io/badge/-development-blue) |
| `aws` | Amazon Web Services | ![Development](https://img.shields.io/badge/-development-blue) |
| `azure` | Microsoft Azure | ![Development](https://img.shields.io/badge/-development-blue) |
| `gcp` | Google Cloud Platform | ![Development](https://img.shields.io/badge/-development-blue) |
| `tencent_cloud` | Tencent Cloud | ![Development](https://img.shields.io/badge/-development-blue) |

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

[FaaS resource attributes]: https://opentelemetry.io/docs/specs/semconv/resource/faas/
[Cloud resource attributes]: https://opentelemetry.io/docs/specs/semconv/resource/cloud/

## 関数トリガーの種類

この節では、`faas.trigger`属性の値に基づいて、スパンの作成方法や追加の属性をどのように扱うかを説明します。

### データソース

<!-- semconv span.faas.datasource.server -->
<!-- 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)

このスパンは、データベースやファイルシステムの読み書きなどのデータソース操作への応答としてトリガーされたFaaS呼び出しのサーバー側を表します。

**スパン種別**は`SERVER`であるべきです（SHOULD）。

**スパンステータス**は[エラーの記録](/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 |
| --- | --- | --- | --- | --- | --- |
| [`faas.document.collection`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | トリガーとなった操作が実行された対象のソース名。たとえば、Cloud StorageやS3ではバケット名に、Cosmos DBではデータベース名に対応します。 | `myBucketName`; `myDbName` |
| [`faas.document.operation`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | データに対して実行された操作の種類を記述します。 | `insert`; `edit`; `delete` |
| [`faas.trigger`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | この関数呼び出しの原因となったトリガーの種類。[1] | `datasource` |
| [`cloud.resource_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/cloud/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 監視対象のクラウドリソースのクラウドプロバイダー固有のネイティブ識別子（AWSの[ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)、Azureの[完全修飾リソースID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id)、GCPの[完全なリソース名](https://google.aip.dev/122#full-resource-names)など）[2] | `arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function`; `//run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID`; `/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>` |
| [`faas.coldstart`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | boolean | サーバーレス関数が初めて実行される場合（コールドスタート）にtrueとなるブール値。 | |
| [`faas.document.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 操作の対象となったドキュメント名・テーブル名。たとえば、Cloud StorageやS3ではファイル名に、Cosmos DBではテーブル名に対応します。 | `myFile.txt`; `myTableName` |
| [`faas.document.time`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | データがアクセスされた時刻を、[UTC](https://www.w3.org/TR/NOTE-datetime)で表現した[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)形式の文字列。 | `2020-01-23T13:47:06Z` |
| [`faas.invocation_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 現在の関数呼び出しの呼び出しID。 | `af9d5aa4-a685-4c5f-a22b-444f80b3cc28` |

**[1] `faas.trigger`:** `datasource`に設定しなければなりません（MUST）。

**[2] `cloud.resource_id`:** 一部のクラウドプロバイダーでは、起動時に完全なIDを判定できない場合があるため、代わりにスパン属性として`cloud.resource_id`を設定する必要があるかもしれません。

`cloud.resource_id`に使用する正確な値は、クラウドプロバイダーによって異なります。
この属性を設定し、かつ次の条件が該当する場合、次のよく知られた定義を使用しなければなりません（MUST）。

- **AWS Lambda:** 関数の[ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)。「invoked ARN」をそのまま使わず、[エイリアスのsuffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)を解決済みの関数バージョンに置き換えるよう注意してください。同一のランタイムインスタンスが複数の異なるエイリアスで呼び出し可能な場合があるためです。
- **GCP:** [リソースのURI](https://cloud.google.com/iam/docs/full-resource-names)。
- **Azure:** 呼び出された関数の[完全修飾リソースID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id)（関数アプリ*ではありません*）。形式は`/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`です。Azureの関数アプリは通常同じTracerProviderを共有する複数の関数をホストできるため、スパン属性を使わなければなりません（MUST）。

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `delete` | オブジェクトが削除された場合。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `edit` | オブジェクトが変更された場合。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `insert` | 新しいオブジェクトが作成された場合。 | ![Development](https://img.shields.io/badge/-development-blue) |

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `datasource` | データベースやファイルシステムの読み書きなど、データソースの操作に対する応答。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `http` | 受信したHTTPリクエストへの応答を提供する。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `other` | 他のいずれにも当てはまらない場合。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `pubsub` | メッセージングシステムにメッセージが送信されたときに実行されるよう設定された関数。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `timer` | 定期的に実行されるようスケジュールされた関数。 | ![Development](https://img.shields.io/badge/-development-blue) |

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

### HTTP

この関数の責務は、受信したHTTPリクエストへの応答を提供することです。`faas`スパンは、[HTTPサーバーのセマンティック規約](/works/otel-specs-ja/semconv/http/http-spans/#httpサーバースパン)に記載されている推奨事項に従うべきです（SHOULD）。

### PubSub

メッセージングシステムにメッセージが送信されたときに実行されるよう、関数が設定されます。
この場合、複数のメッセージがバッチ化され、同じ関数呼び出しに一度に転送されることがあります。
したがって、関数によって処理される各メッセージについて、[メッセージングシステムのセマンティック規約](/works/otel-specs-ja/semconv/messaging/messaging-spans/)に従い、`faas`型の異なるルートスパンを作成しなければなりません（MUST）。
これにより、個々のメッセージをその呼び出し元と関連付けられるようになります。

### タイマー

定期的に実行されるよう、関数がスケジュールされます。次の追加の属性が推奨されます。

<!-- semconv span.faas.timer.server -->
<!-- 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)

このスパンは、タイマーによってトリガーされたFaaS呼び出しのサーバー側を表します。

**スパン種別**は`SERVER`であるべきです（SHOULD）。

**スパンステータス**は[エラーの記録](/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 |
| --- | --- | --- | --- | --- | --- |
| [`faas.trigger`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Required` | string | この関数呼び出しの原因となったトリガーの種類。[1] | `timer` |
| [`cloud.resource_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/cloud/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 監視対象のクラウドリソースのクラウドプロバイダー固有のネイティブ識別子（AWSの[ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)、Azureの[完全修飾リソースID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id)、GCPの[完全なリソース名](https://google.aip.dev/122#full-resource-names)など）[2] | `arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function`; `//run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID`; `/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>` |
| [`faas.coldstart`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | boolean | サーバーレス関数が初めて実行される場合（コールドスタート）にtrueとなるブール値。 | |
| [`faas.cron`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | [Cron式](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm)としてスケジュール期間を含む文字列。 | `0/5 * * * ? *` |
| [`faas.invocation_id`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 現在の関数呼び出しの呼び出しID。 | `af9d5aa4-a685-4c5f-a22b-444f80b3cc28` |
| [`faas.time`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/faas/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | 関数の呼び出し時刻を、[UTC](https://www.w3.org/TR/NOTE-datetime)で表現した[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)形式の文字列。 | `2020-01-23T13:47:06Z` |

**[1] `faas.trigger`:** `timer`に設定しなければなりません（MUST）。

**[2] `cloud.resource_id`:** 一部のクラウドプロバイダーでは、起動時に完全なIDを判定できない場合があるため、代わりにスパン属性として`cloud.resource_id`を設定する必要があるかもしれません。

`cloud.resource_id`に使用する正確な値は、クラウドプロバイダーによって異なります。
この属性を設定し、かつ次の条件が該当する場合、次のよく知られた定義を使用しなければなりません（MUST）。

- **AWS Lambda:** 関数の[ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)。「invoked ARN」をそのまま使わず、[エイリアスのsuffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)を解決済みの関数バージョンに置き換えるよう注意してください。同一のランタイムインスタンスが複数の異なるエイリアスで呼び出し可能な場合があるためです。
- **GCP:** [リソースのURI](https://cloud.google.com/iam/docs/full-resource-names)。
- **Azure:** 呼び出された関数の[完全修飾リソースID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id)（関数アプリ*ではありません*）。形式は`/subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>`です。Azureの関数アプリは通常同じTracerProviderを共有する複数の関数をホストできるため、スパン属性を使わなければなりません（MUST）。

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `datasource` | データベースやファイルシステムの読み書きなど、データソースの操作に対する応答。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `http` | 受信したHTTPリクエストへの応答を提供する。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `other` | 他のいずれにも当てはまらない場合。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `pubsub` | メッセージングシステムにメッセージが送信されたときに実行されるよう設定された関数。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `timer` | 定期的に実行されるようスケジュールされた関数。 | ![Development](https://img.shields.io/badge/-development-blue) |

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

### その他

Function as a Serviceは非常に柔軟であり、セマンティック規約だけでは完全に対応できません。
関数が前述のいずれの場合にも該当しない場合、スパンは属性`faas.trigger`を`"other"`に設定しなければなりません（MUST）。
この場合、最も適切な属性を定義する責任は、フレームワークまたは計装ライブラリにあります。

## 例

この例は、Google Cloud Platform上でホストされている（FaaSではない）プロセス（種別`CLIENT`のスパンA）が、Amazon Web Servicesで「my-lambda-function」というLambda関数を呼び出す場合（種別`SERVER`のスパンB）のFaaS属性を示しています。

| Attribute Kind | Attribute               | Span A (Client, GCP)   | Span B (Server, AWS Lambda)                                           |
| -------------- | ----------------------- | ---------------------- | --------------------------------------------------------------------- |
| Resource       | `cloud.provider`        | `"gcp"`                | `"aws"`                                                               |
| Resource       | `cloud.region`          | `"europe-west3"`       | `"eu-central-1"`                                                      |
| Span           | `faas.invoked_name`     | `"my-lambda-function"` | n/a                                                                   |
| Span           | `faas.invoked_provider` | `"aws"`                | n/a                                                                   |
| Span           | `faas.invoked_region`   | `"eu-central-1"`       | n/a                                                                   |
| Span           | `faas.trigger`          | n/a                    | `"http"`                                                              |
| Span           | `faas.invocation_id`    | n/a                    | `"af9d5aa4-a685-4c5f-a22b-444f80b3cc28"`                              |
| Span           | `faas.coldstart`        | n/a                    | `true`                                                                |
| Resource       | `faas.name`             | n/a                    | `"my-lambda-function"`                                                |
| Resource       | `faas.version`          | n/a                    | `"semver:2.0.0"`                                                      |
| Resource       | `faas.instance`         | n/a                    | `"my-lambda-function:instance-0001"`                                  |
| Resource       | `cloud.resource_id`     | n/a                    | `"arn:aws:lambda:us-west-2:123456789012:function:my-lambda-function"` |

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

