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


# FaaS例外に関するセマンティック規約

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

この文書では、FaaSの呼び出しにおいて例外を記録するためのセマンティック規約を定義します。

## FaaS呼び出しの例外

<!-- semconv event.faas.invocation.exception -->
<!-- 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.invocation.exception`でなければなりません（MUST）。

このイベントは、アプリケーションエラー、内部障害、または関数が正常に完了することを妨げるその他の例外など、FaaS関数の呼び出し中に発生した例外を表します。

このイベントは、FaaS関数の呼び出し中に例外が発生した場合に記録されるべきです（SHOULD）。計装は、このイベントを記録する際にseverityをERROR（severity number 17）に設定すべきです（SHOULD）。計装は、対応するFaaSスパンで捕捉された属性で例外イベントを補完するための設定オプションを提供してもかまいません（MAY）。

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`exception.message`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/exception/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` [1] | string | 例外メッセージ。[2] | `Division by zero`; `Can't convert 'int' object to str implicitly` |
| [`exception.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/exception/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Conditionally Required` [3] | string | 例外の型（該当する場合はその完全修飾クラス名）。この動的な型に対応する言語では、静的な型よりも動的な型を優先すべきです。[4] | `java.net.ConnectException`; `OSError` |
| [`exception.stacktrace`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/exception/) | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | `Recommended` | string | 言語ランタイムの自然な表現による文字列としてのスタックトレース。この表現は、各言語のSIGによって決定・文書化されるものとします。 | `Exception in thread "main" java.lang.RuntimeException: Test exception\n at com.example.GenerateTrace.methodB(GenerateTrace.java:13)\n at com.example.GenerateTrace.methodA(GenerateTrace.java:9)\n at com.example.GenerateTrace.main(GenerateTrace.java:5)` |

**[1] `exception.message`:** `exception.type`が設定されていない場合は必須で、それ以外の場合は推奨です。

**[2] `exception.message`:**

> [!WARNING]
>
> この属性には機密情報が含まれる可能性があります。

**[3] `exception.type`:** `exception.message`が設定されていない場合は必須で、それ以外の場合は推奨です。

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

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

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

