> Source: https://www.ymotongpoo.com/works/otel-specs-ja/semconv/mobile/mobile-events/


# モバイルイベントに関するセマンティック規約

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

この文書では、モバイルプラットフォーム上でイベントを発行する計装のためのセマンティック規約を定義します。すべてのモバイルイベントは、EventNameのLogRecordプロパティに`device`という名前空間を使わなければなりません（MUST）。

## ライフサイクル計装

この節では、アプリケーションのライフサイクルを計装するときのセマンティック規約の適用方法を定義します。

### イベント: `device.app.lifecycle`

<!-- semconv event.device.app.lifecycle -->
<!-- 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)

イベント名は`device.app.lifecycle`でなければなりません（MUST）。

このイベントは、AndroidまたはiOSプラットフォーム上でのライフサイクル遷移の発生を表します。

イベントのbodyフィールドは、イベント発生時点のアプリケーションの状態を記述するために使用しなければなりません（MUST）。このイベントは、モバイルOS（Android、iOSなど）を識別する`os.name` [リソースセマンティック規約](https://opentelemetry.io/docs/specs/semconv/resource/os/)と併用することを意図しています。`android.app.state`フィールドと`ios.app.state`フィールドは相互排他的であり、併用してはなりません（MUST NOT）。各フィールドは、対応する`os.name`の値とともに使用しなければなりません（MUST）。

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`android.app.state`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/android/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` if and only if `os.name` is `android` | string | この属性は、アプリケーションの状態を表します。[1] | `created` |
| [`ios.app.state`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/ios/) | ![Development](https://img.shields.io/badge/-development-blue) | `Conditionally Required` if and only if `os.name` is `ios` | string | この属性は、アプリケーションの状態を表します。[2] | `active`; `inactive`; `background` |

**[1] `android.app.state`:** Androidのライフサイクル状態は[Activity lifecycle callbacks](https://developer.android.com/guide/components/activities/activity-lifecycle#lifecycle-callbacks)で定義されており、そこから`OS identifiers`が導出されます。

**[2] `ios.app.state`:** iOSのライフサイクル状態は[UIApplicationDelegateのドキュメント](https://developer.apple.com/documentation/uikit/uiapplicationdelegate)で定義されており、そこから`OS terminology`列の値が導出されます。

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `background` | アプリがフォアグラウンド状態にあったときに、Activity.onPause()が呼び出された後、またはアプリにActivityがない場合はContext.stopService()が呼び出された後の任意の時点。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `created` | アプリで初めてActivity.onResume()が呼び出される前、またはアプリにActivityがない場合はContext.startService()が呼び出される前の任意の時点。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `foreground` | アプリがcreated状態またはbackground状態にあったときに、Activity.onResume()が呼び出された後、またはアプリにActivityがない場合はContext.startService()が呼び出された後の任意の時点。 | ![Development](https://img.shields.io/badge/-development-blue) |

---

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

| Value | Description | Stability |
| --- | --- | --- |
| `active` | アプリが`active`になりました。UIKit通知`applicationDidBecomeActive`に対応します。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `background` | アプリが現在バックグラウンドにあります。この値はUIKit通知`applicationDidEnterBackground`に対応します。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `foreground` | アプリが現在フォアグラウンドにあります。この値はUIKit通知`applicationWillEnterForeground`に対応します。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `inactive` | アプリが現在`inactive`です。UIKit通知`applicationWillResignActive`に対応します。 | ![Development](https://img.shields.io/badge/-development-blue) |
| `terminate` | アプリが終了しようとしています。UIKit通知`applicationWillTerminate`に対応します。 | ![Development](https://img.shields.io/badge/-development-blue) |

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

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

