---
title: OpenTelemetryスパンリファレンス
url: https://platform.claude.com/docs/ja/api/opentelemetry/spans
description: Claude APIとClaude SDKが出力するOpenTelemetryのスパンとスパン属性。
featureMetadata:
  topic:
    title: OpenTelemetry
    url: https://platform.claude.com/docs/en/manage-claude/opentelemetry
  status: beta
---

<Note>
  OpenTelemetryエクスポートはベータ版です。[サービス固有規約](https://www.anthropic.com/legal/service-specific-terms)のベータサービスのセクションを含む、Anthropicとの契約に基づいて提供されます。スパン名と属性はベータ期間中に変更される可能性があります。
</Note>

エクスポートを設定するには、[Claude SDKでOpenTelemetryを使用する](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk)および[Claude APIでOpenTelemetryを使用する](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api)を参照してください。

## スパン名と種類

| プロパティ            | SDKスパン                                                                                                                | APIスパン                               |
| ---------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `service.name`   | アプリケーションの`service.name`                                                                                               | `claude-platform`                    |
| インストルメンテーションスコープ | `com.anthropic.sdk.<language>` または `com.anthropic.sdk.cli`（クラウドプラットフォームのクライアントではさらに `.<platform>` が付加）、およびパッケージのバージョン | `com.anthropic.claude-platform`      |
| スパンの種類           | リクエストのスパンでは`CLIENT`、それ以外では`INTERNAL`                                                                                  | リクエストのスパンでは`SERVER`、それ以外では`INTERNAL` |

* **リクエストのスパン**は、そのリクエストのAPIメソッドの名前を持ちます。これは`anthropic.`の後に、APIリファレンスにおけるメソッドのパスを、スラッシュの代わりにドットを使い、`beta`を除いた形で続けたものです。たとえば、`client.beta.sessions.events.send()` (csharp, go: `client.Beta.Sessions.Events.Send()`; java: `client.beta().sessions().events().send()`; php: `$client->beta->sessions->events->send()`; ruby: `client.beta.sessions.events.send_()`)は[セッションイベントを送信する](https://platform.claude.com/docs/ja/api/beta/sessions/events/send)リクエストを送信し、そのスパンの名前は[`anthropic.sessions.events.send`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-events-send)になります。
* **ツールスパン**は、固定の名前、スペース、ツール名で構成される名前を持ちます。たとえば[`anthropic.tool_use bash`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)です。

## スパンのステータス

* **`OK`：** ステップが完了しました。
* **`ERROR`：** ステップが失敗しました。
* **未設定：** アプリケーションがステップをキャンセルしました。たとえば、[`user.interrupt`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_user_interrupt_event)イベントを送信した場合です。

ストリームのスパンは、ストリームが終了したときに終了します。アプリケーションがストリームを早期に閉じた場合、SDKスパンのステータスは未設定になります。そのため、[`anthropic.sessions.events.stream`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-method)のように完了しないストリームのSDKスパンは、ステータスが未設定または`ERROR`になります。

## 属性

属性は、該当するものが存在する場合、[生成AI向けのOpenTelemetryセマンティック規約](https://github.com/open-telemetry/semantic-conventions-genai)（`gen_ai.*`）を使用します。Anthropicの属性は`anthropic.`で始まります。スパンは、2026年9月24日のコミット[`e57c543b`](https://github.com/open-telemetry/semantic-conventions-genai/tree/e57c543b4889619eb2a05702471937db5119165d)時点の規約に従います。この規約はまだ開発中です。

### 共通属性

リクエストのすべてのスパンは、説明に別途記載がある場合を除き、次の属性を持ちます。他のスパンは最初の3つの属性のみを持つことがあります。

| 属性                          | 型        | 説明                                                                                                                                                 |
| --------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.provider.name`      | `string` | `anthropic`。すべてのスパンに付与されます。<br />**SDK：** Amazon Bedrockクライアント（Mantleを含む）では`aws.bedrock`、Google Cloud's Agent Platform用のクライアントでは`gcp.vertex_ai`です。 |
| `anthropic.organization.id` | `string` | 組織のID。                                                                                                                                             |
| `anthropic.workspace.id`    | `string` | 処理が実行されるワークスペースのID。                                                                                                                                |
| `anthropic.request.id`      | `string` | `request-id`レスポンスヘッダーの値です。                                                                                                                         |
| `http.request.method`       | `string` | リクエストのHTTPメソッド（例：`POST`）。                                                                                                                          |
| `http.route`                | `string` | エンドポイントのパス。パスパラメーターはプレースホルダーで表されます（例：`/v1/sessions/{session_id}`）。                                                                                 |
| `http.response.status_code` | `int`    | 最終レスポンスのHTTPステータスコード。ストリームの場合は、ヘッダーとともに送信されたステータスコードです。レスポンスがなかった場合は存在しません。                                                                        |
| `server.address`            | `string` | リクエストの送信先ホスト（例：`api.anthropic.com`）。                                                                                                               |
| `server.port`               | `int`    | リクエストURLのポート。URLにポートがない場合はそのスキームのデフォルトポート。                                                                                                         |
| `url.scheme`                | `string` | URLのスキーム（例：`https`）。                                                                                                                               |
| `url.path`                  | `string` | URLのパス（例：`/v1/messages`）。                                                                                                                          |
| `url.query`                 | `string` | URLのクエリ文字列。エンドポイントで定義されているクエリパラメーターのみを含みます。該当するパラメーターがない場合は存在しません。                                                                                 |
| `url.full`                  | `string` | リクエストのURL。                                                                                                                                         |

Claude Platform on AWS では、API スパンに `server.address`、`server.port`、`url.full` は含まれません。

### セッション属性

Managed Agentsセッションでは、スパンは次の属性を持ちます。セッションのスパンは複数のトレースにまたがる場合があるため、トランスクリプトなどのセッションのビューを組み立てるには、[これらのIDでスパンをグループ化](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#a-managed-agents-session)してください。

| 属性                       | 型        | 説明                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `anthropic.session.id`   | `string` | セッションID。[`anthropic.sessions.list`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-method)など、1つのセッションに作用しないメソッドのスパンには存在しません。                                                                                                                                                                                                            |
| `gen_ai.conversation.id` | `string` | スパンが属するセッションスレッドのID。SDKの[`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`)オプション](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#configure-the-sdk)によって、独自の会話IDに置き換えられます。スレッドのないSDKのスパンには、オプションを設定しない限り存在せず、1つのスレッドへのリクエスト以外のSessions APIリクエストのAPIのスパンにも存在しません。 |

### コンテンツ属性

<Badge>Content</Badge>のタグが付いた属性は、SDKとAPIのどちらでも、コンテンツモードのスパンにのみ存在します。[ガイドでコンテンツモードの違い](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#choose-a-content-mode)を参照してください。このコンテンツが大きすぎる場合、SDKとAPIはコンテンツを[短縮](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#content-limits)し、`anthropic.content.truncated`を`true`に設定します。Anthropicのセーフガードがレスポンスからコンテンツを差し控えた場合、APIのスパンにもそのコンテンツは含まれません。

メッセージ属性は、OpenTelemetry GenAI規約のメッセージ形式によるJSON文字列です。Messages APIおよび`agent.message`などのManaged Agentsメッセージイベントにおいて、各Anthropicコンテンツブロックは1つのGenAI規約メッセージパートになります。

| Anthropicコンテンツブロック                                                        | GenAI規約メッセージパート                                                                                    |
| ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `text`                                                                    | `text`                                                                                             |
| `tool_use`、`server_tool_use`                                              | `tool_call`、`computer`などの`toolset_name`を持つ`tool_use`ブロックの場合は`anthropic_toolset_name`付き             |
| `mcp_tool_use`                                                            | `anthropic_mcp_server_name`を持つ`tool_call`                                                          |
| `tool_result`、`mcp_tool_result`、`web_search_tool_result`などのサーバーツールの結果ブロック | `tool_call_response`                                                                               |
| `thinking`                                                                | `reasoning`（`thinking`ブロックの署名は持たない）。`agent.thinking`イベントには思考の内容が含まれないため、Managed Agentsのスパンには含まれない。 |
| `image`などのその他のブロック                                                        | ブロックの`type`に接頭辞`anthropic_`を付けたもの（`anthropic_image`など）。このパートは、ほかのフィールドを持ちません。                      |

Managed Agentsの各ツール使用イベントまたはツール結果イベントも、1つのGenAI規約メッセージパートになります。

| Managed Agentsイベント                                                                       | GenAI規約メッセージパート                           |
| ---------------------------------------------------------------------------------------- | ----------------------------------------- |
| `agent.tool_use`、`agent.custom_tool_use`                                                 | `tool_call`                               |
| `agent.mcp_tool_use`                                                                     | `anthropic_mcp_server_name`を持つ`tool_call` |
| `user.tool_result`、`user.custom_tool_result`、`agent.tool_result`、`agent.mcp_tool_result` | `tool_call_response`                      |

### トークン使用量

次のスパンはトークン使用量の属性を持ちます：[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)、[`anthropic.model_request`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-model-request)、[`anthropic.compaction`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-compaction)、[`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-outcome-evaluation)。値は、リクエスト、モデルリクエスト、コンパクションなど、各スパンのステップに対するものです。各トークンを1回だけカウントするには、[ガイドのトークンのカウント方法](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#count-tokens)を参照してください。

| 属性                                                         | 型     | 説明                                                                                                                                                                                   |
| ---------------------------------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gen_ai.usage.input_tokens`                                | `int` | 入力トークン。キャッシュの読み取りと書き込みを含みます。                                                                                                                                                         |
| `gen_ai.usage.output_tokens`                               | `int` | 出力トークン。                                                                                                                                                                              |
| `gen_ai.usage.cache_write.input_tokens`                    | `int` | プロンプトキャッシングのキャッシュに書き込まれたトークン。[`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-outcome-evaluation)スパンには存在しません。  |
| `anthropic.usage.cache_creation.ephemeral_5m_input_tokens` | `int` | 5分間キャッシュに書き込まれたトークン。Messages APIリクエストのスパンにのみ存在します。ストリーミングレスポンスのSDKスパンでは、最初の出力トークンより前に書き込まれたトークンのみです。                                                                                 |
| `anthropic.usage.cache_creation.ephemeral_1h_input_tokens` | `int` | 1時間キャッシュに書き込まれたトークン。Messages APIリクエストのスパンにのみ存在します。ストリーミングレスポンスのSDKスパンでは、最初の出力トークンより前に書き込まれたトークンのみです。                                                                                 |
| `gen_ai.usage.cache_read.input_tokens`                     | `int` | プロンプトキャッシングのキャッシュから読み取られたトークン。[`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-outcome-evaluation)スパンには存在しません。 |

## スパン

「span」（スパン）は、アプリケーション内のSDKから、またはAPIから出力されるため、このリファレンスの各スパンにはその出力元が記載されています。**Messages API：**&#x307E;たは**Managed Agents：**&#x3067;始まる説明は、その製品のスパンに関するものです。**SDK：**&#x3084;**API：**&#x306A;どの出力元で始まる属性の説明は、その出力元のスパンに関するものです。

### `anthropic.messages.create`

* **出力元：** SDKとAPI。
* **種類：** SDKからは`CLIENT`、APIからは`SERVER`。
* **SDKスパンの親：** アプリケーションがメソッドを呼び出した時点でアプリケーション内で現在のスパン。現在のスパンがない場合、親はありません。
* **APIスパンの親：** リクエストの`traceparent`ヘッダー内のスパン。リクエストがSDKから送信された場合はSDKスパンです。ヘッダーがない場合、APIスパンには親がありません。[`traceparent`ヘッダーの送信方法](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#connect-api-spans-to-your-own-traces)を参照してください。
* **SDKスパンの子：** そのリクエストのAPIのスパン。
* **APIスパンの子：** 各モデルリクエストの[`anthropic.model_request`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-model-request)スパン、APIがリクエスト内で実行するサーバーツールまたはMCPコネクタツールの各使用の[ツールスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)、および各コンパクションの[`anthropic.compaction`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-compaction)スパン。

SDKは、ストリーミングかどうかにかかわらず、各Messagesリクエストに対してこのスパンを出力します。

APIは、認証した各[`POST /v1/messages`](https://platform.claude.com/docs/ja/api/messages/create)リクエストに対してこのスパンを出力します。[OpenAI互換エンドポイント](https://platform.claude.com/docs/ja/cli-sdks-libraries/libraries/openai-sdk)である`POST /v1/chat/completions`へのリクエストに対しては、このスパンを出力しません。

APIは、[フォールバックモデル](https://platform.claude.com/docs/ja/build-with-claude/refusals-and-fallback)がリクエストを処理した場合でも、1つのリクエストに対して1つのスパンを出力します。

このスパンは[トークン使用量の属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#token-usage)を持ちます。SDKスパンは、すべての[リクエストのSDKスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-resources-method)の属性も持ちます。

| 属性                                         | 型          | 説明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`                    | `string`   | `chat`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.request.model`                     | `string`   | リクエストの[`model`](https://platform.claude.com/docs/ja/api/messages/create#create.model)。                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.response.id`                       | `string`   | レスポンスの[`id`](https://platform.claude.com/docs/ja/api/messages/create#message)。                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `gen_ai.response.model`                    | `string`   | リクエストを処理したモデル。リクエストがモデルエイリアスを使用している場合や、[フォールバックモデル](https://platform.claude.com/docs/ja/build-with-claude/refusals-and-fallback)がリクエストを処理した場合は、リクエストされたモデルと異なります。                                                                                                                                                                                                                                                                                                                                           |
| `anthropic.message.stop_reason`            | `string`   | レスポンスの[`stop_reason`](https://platform.claude.com/docs/ja/api/messages#stop_reason)。たとえば`end_turn`です。                                                                                                                                                                                                                                                                                                                                                                                                       |
| `anthropic.response.service_tier`          | `string`   | リクエストを処理したサービスティア。レスポンスの[`usage.service_tier`](https://platform.claude.com/docs/ja/api/messages#usage)です。[リクエストへのティアの割り当て方法](https://platform.claude.com/docs/ja/api/service-tiers#how-requests-get-assigned-tiers)を参照してください。                                                                                                                                                                                                                                                                               |
| `error.type`                               | `string`   | 失敗したリクエストの[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)。たとえば`rate_limit_error`です。<br />**SDK：** [リクエストのSDKスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-resources-method)に記載されているその他の値も含みます。<br />**API：** APIがエラーレスポンスなしでリクエストを終了した場合は`api_error`です。                                                                                                                                                                                                   |
| `gen_ai.response.time_to_first_chunk`      | `double`   | ストリーミングレスポンスのSDKスパンにのみ存在します。SDKが最初にリクエストを送信してから、ストリームの最初の`content_block_delta`イベント（存在する場合）までの秒数です。                                                                                                                                                                                                                                                                                                                                                                                                          |
| `gen_ai.usage.reasoning.output_tokens`     | `int`      | レスポンスの思考トークン。出力トークンの一部です。レスポンスの使用量に出力トークンの詳細がない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `anthropic.usage.compaction.input_tokens`  | `int`      | リクエストの[コンパクション](https://platform.claude.com/docs/ja/build-with-claude/compaction)の入力トークン。キャッシュの読み取りと書き込みを含みます。`gen_ai.usage.input_tokens`には含まれません。レスポンスにコンパクションがない場合は存在しません。                                                                                                                                                                                                                                                                                                                                |
| `anthropic.usage.compaction.output_tokens` | `int`      | リクエストのコンパクションの出力トークン。`gen_ai.usage.output_tokens`には含まれません。レスポンスにコンパクションがない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `gen_ai.request.max_tokens`                | `int`      | リクエストの[`max_tokens`](https://platform.claude.com/docs/ja/api/messages/create#create.max_tokens)。                                                                                                                                                                                                                                                                                                                                                                                                            |
| `gen_ai.request.temperature`               | `double`   | リクエストの[`temperature`](https://platform.claude.com/docs/ja/api/messages/create#create.temperature)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                  |
| `gen_ai.request.top_p`                     | `double`   | リクエストの[`top_p`](https://platform.claude.com/docs/ja/api/messages/create#create.top_p)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                              |
| `gen_ai.request.top_k`                     | `int`      | リクエストの[`top_k`](https://platform.claude.com/docs/ja/api/messages/create#create.top_k)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                              |
| `gen_ai.request.stream`                    | `boolean`  | リクエストで[`stream: true`](https://platform.claude.com/docs/ja/api/messages/create#create.stream)が設定されている場合は`true`。それ以外の場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                              |
| `gen_ai.request.reasoning.level`           | `string`   | リクエストの[`output_config`](https://platform.claude.com/docs/ja/api/messages/create#create.output_config)内の[`effort`](https://platform.claude.com/docs/ja/api/messages/create#create.output_config.effort)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                             |
| `gen_ai.output.type`                       | `string`   | リクエストで出力形式がJSONに設定されている場合は`json`。それ以外の場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `anthropic.request.service_tier`           | `string`   | リクエストの[`service_tier`](https://platform.claude.com/docs/ja/api/messages/create#create.service_tier)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                |
| `anthropic.thinking.type`                  | `string`   | リクエストの[`thinking.type`](https://platform.claude.com/docs/ja/api/messages/create#create.thinking)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                   |
| `anthropic.thinking.budget_tokens`         | `int`      | リクエストの[`thinking`](https://platform.claude.com/docs/ja/api/messages/create#create.thinking)オブジェクト内の[`budget_tokens`](https://platform.claude.com/docs/ja/api/messages#thinking_config_enabled.budget_tokens)。リクエストで設定されていない場合は存在しません。                                                                                                                                                                                                                                                                       |
| `anthropic.beta`                           | `string[]` | SDKスパンにのみ存在します。リクエストの[`anthropic-beta`](https://platform.claude.com/docs/ja/api/beta/messages/create#create.betas)ヘッダー内のベータ名です。                                                                                                                                                                                                                                                                                                                                                                             |
| `gen_ai.system_instructions`               | `string`   | <Badge>Content</Badge> OpenTelemetryの[`SystemInstructions`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-system-instructions.json)スキーマに従うJSON文字列。リクエストの[`system`](https://platform.claude.com/docs/ja/api/messages/create#create.system)プロンプトです。                                                                                                                                                                          |
| `gen_ai.input.messages`                    | `string`   | <Badge>Content</Badge> OpenTelemetryの[`InputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-input-messages.json)スキーマに従うJSON文字列。リクエストの[`messages`](https://platform.claude.com/docs/ja/api/messages/create#create.messages)です。                                                                                                                                                                                     |
| `gen_ai.output.messages`                   | `string`   | <Badge>Content</Badge> OpenTelemetryの[`OutputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-output-messages.json)スキーマに従うJSON文字列。レスポンスの[`content`](https://platform.claude.com/docs/ja/api/messages/create#message)を1つの`assistant`メッセージとしたものです。<br />**SDK：** ストリームでは、[ストリームのトレース](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#trace-a-stream)で説明されているとおりにアプリケーションがストリームを読み取った場合にのみ存在します。 |
| `gen_ai.request.stop_sequences`            | `string[]` | <Badge>Content</Badge> リクエストの[`stop_sequences`](https://platform.claude.com/docs/ja/api/messages/create#create.stop_sequences)。                                                                                                                                                                                                                                                                                                                                                                             |

リクエストのスパンは、`web_search_requests`などのレスポンスのサーバーツール使用回数を持ちません。代わりに、APIはサーバーツールの各使用に対して[ツールスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)を出力します。

### `anthropic.messages.count_tokens`

* **出力元：** SDK。APIは[`POST /v1/messages/count_tokens`](https://platform.claude.com/docs/ja/api/messages/count_tokens)に対してスパンを出力しません。
* **種類：** `CLIENT`。
* **親：** アプリケーションがメソッドを呼び出した時点でアプリケーション内で現在のスパン。現在のスパンがない場合はなし。
* **子：** なし。

| 属性                                            | 型        | 説明                                                       |
| --------------------------------------------- | -------- | -------------------------------------------------------- |
| `gen_ai.request.model`                        | `string` | リクエストのモデル。                                               |
| `anthropic.message.count_tokens.input_tokens` | `int`    | レスポンス内のトークン数。このカウントは使用量ではありません。トークン使用量を合計する際には含めないでください。 |

### `anthropic.sessions.create`

次の子と属性を除き、[`anthropic.sessions.<method>`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-method)と同じです。

* **SDKスパンの子：** そのリクエストのAPIのスパン。
* **APIスパンの子：** リクエストに空でない[`initial_events`](https://platform.claude.com/docs/ja/api/beta/sessions/create#create.initial_events)がある場合、最初のターンの[`anthropic.session.turn`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)スパン。

| 属性                                 | 型        | 説明                                                              |
| ---------------------------------- | -------- | --------------------------------------------------------------- |
| `gen_ai.agent.id`                  | `string` | セッションの作成元となったエージェントのID。                                         |
| `gen_ai.agent.name`                | `string` | そのエージェントの名前。<br />**SDK：** リクエストが失敗した場合は存在しません。                 |
| `gen_ai.request.model`             | `string` | プライマリスレッドを実行する、そのエージェントのモデル。<br />**SDK：** リクエストが失敗した場合は存在しません。 |
| `anthropic.session.environment.id` | `string` | セッションの環境のID。                                                    |

### `anthropic.sessions.events.send`

APIスパンの子を除き、[`anthropic.sessions.<method>`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-method)と同じです。

* **SDKスパンの子：** そのリクエストに対するAPIのスパン。
* **APIスパンの子：** リクエストのイベントによって開始される各ターンの[`anthropic.session.turn`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)スパン。

### `anthropic.sessions.update`

APIスパンの子を除き、[`anthropic.sessions.<method>`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-method)と同じです。

* **SDKスパンの子：** そのリクエストに対するAPIのスパン。
* **APIスパンの子：** リクエストが[セッション予算](https://platform.claude.com/docs/ja/managed-agents/budgets#resume-a-session-at-its-budget)を引き上げるか削除したことによって再開される各ターンの[`anthropic.session.turn`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)スパン。

### `anthropic.session.turn`

* **出力元：** Managed AgentsセッションのAPI。

* **種類：** `INTERNAL`。

* **親：** ターンが開始された理由によって異なります。

  * 空でない[`initial_events`](https://platform.claude.com/docs/ja/api/beta/sessions/create#create.initial_events)で作成されたセッションの最初のターンの場合、[`anthropic.sessions.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-create)スパン。
  * イベント（たとえば[`user.message`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_user_message_event)イベント）によって開始されたターンの場合、そのイベントが送信されたリクエストの[`anthropic.sessions.events.send`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-events-send)スパン。
  * リクエストによってセッション予算が引き上げられたか削除されたために再開されるターンの場合、[`anthropic.sessions.update`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-sessions-update)スパン。
  * 別のスレッド上のターンの場合、[セッションが実行するエージェント](https://platform.claude.com/docs/ja/managed-agents/multiagent-orchestration)のターンのうち、そのエージェントがこのターンを開始したターンの `anthropic.session.turn` スパン。
  * 別のスレッド上のエージェント（プライマリエージェントが呼び出したエージェントなど）が返信した、またはターンを終了したために開始されるターンの場合、なし。

* **子：**

  * ターン内の各モデルリクエストの[`anthropic.model_request`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-model-request)スパン。
  * APIがターン内でツールを実行するたびのツールスパン。ただし、[ツールスパンのセクションに記載されているケース](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)を除きます。
  * このターン中にセッションが実行するエージェントが別のスレッドで開始した各ターンの`anthropic.session.turn`スパン。
  * このターンが開始するアウトカム評価の各イテレーションの[`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-outcome-evaluation)スパン。

ターンは、そのスレッドが`running`状態に入ったときに開始し、スレッドがその状態を離れたときに終了します。

| 属性                                   | 型        | 説明                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`              | `string` | `invoke_agent`                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `gen_ai.agent.id`                    | `string` | ターンのスレッドを実行するエージェントのID。[アドバイザー](https://platform.claude.com/docs/ja/managed-agents/multiagent-orchestration#advisor-threads)スレッドには存在しません。                                                                                                                                                                                                                                                                                         |
| `gen_ai.agent.name`                  | `string` | そのエージェントの名前。アドバイザースレッドでは`anthropic.advisor`です。                                                                                                                                                                                                                                                                                                                                                                                    |
| `gen_ai.request.model`               | `string` | そのエージェントのモデル。アドバイザースレッドでは、アドバイザーのモデルです。                                                                                                                                                                                                                                                                                                                                                                                           |
| `anthropic.session.turn.stop_reason` | `string` | ターンが終了した理由。[`session.thread_status_idle`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_session_thread_status_idle_event)イベントの[`stop_reason.type`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_session_thread_status_idle_event)で、たとえば`requires_action`です。スレッドがアイドル状態にならなかった場合は存在しません。                                                                    |
| `error.type`                         | `string` | ターンが失敗した場合、ターンを終了させた[`session.error`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_session_error_event)イベントの[`error.type`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_session_error_event)。                                                                                                                                                             |
| `gen_ai.agent.description`           | `string` | そのエージェントの説明。アドバイザースレッドの場合、またはエージェントに説明がない場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                               |
| `gen_ai.system_instructions`         | `string` | <Badge>Content</Badge> OpenTelemetryの[`SystemInstructions`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-system-instructions.json)スキーマに従うJSON文字列。ターンで有効なシステムプロンプトです。スレッドの最初のターンにのみ存在します。アドバイザースレッドには存在しません。                                                                                                                                     |
| `gen_ai.input.messages`              | `string` | <Badge>Content</Badge> OpenTelemetryの[`InputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-input-messages.json)スキーマに従うJSON文字列。ターンの入力イベントで、ユーザーメッセージとツール結果、[`system.message`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_system_message_event_params)イベント、および他のスレッドからのメッセージです。アドバイザースレッドには存在しません。 |
| `gen_ai.output.messages`             | `string` | <Badge>Content</Badge> OpenTelemetryの[`OutputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-output-messages.json)スキーマに従うJSON文字列。ターンの出力イベントで、エージェントのメッセージ、ツール使用、ツール結果です。                                                                                                                                                                |

### `anthropic.model_request`

* **出力元：** Messages APIリクエストおよびManaged AgentsセッションのAPI。

* **種類：** `INTERNAL`。

* **親：**

  * **Messages API：** リクエストの[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパン。
  * **Managed Agents：** リクエストを行うターンの[`anthropic.session.turn`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)スパン。

* **子：** なし。

Messages APIでは、各スパンはAPIリクエスト内の1つのモデルリクエストです。

このスパンは[トークン使用量の属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#token-usage)を持ちます。

| 属性                      | 型        | 説明                                                                                                                                                                                                                                                                                                                                                               |
| ----------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name` | `string` | Managed Agentsセッションのスパンにのみ存在し、値は`chat`です。Messages APIでは、リクエストの[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパンが`chat`オペレーションです。                                                                                                                                                           |
| `gen_ai.request.model`  | `string` | リクエストのモデル。                                                                                                                                                                                                                                                                                                                                                       |
| `gen_ai.response.model` | `string` | Messages APIリクエストのスパンにのみ存在します。モデルリクエストを実行したモデルです。                                                                                                                                                                                                                                                                                                                |
| `error.type`            | `string` | **Messages API：** このモデルリクエスト中にリクエストが失敗した場合、[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパンの`error.type`。<br />**Managed Agents：** モデルリクエストが失敗した場合、その[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)。たとえば`rate_limit_error`です。モデルリクエストがレスポンスなしで失敗した場合は`api_error`です。 |

### `anthropic.tool_use`、`anthropic.mcp_tool_use`、`anthropic.custom_tool_use`

* **出力元：** SDKとAPI。

* **名前：** `anthropic.tool_use <tool>`、`anthropic.mcp_tool_use <tool>`、または`anthropic.custom_tool_use <tool>`。`<tool>`はツールの名前です。

* **種類：** `INTERNAL`。

* **SDKスパンの親：** ツールが開始した時点でアプリケーション内で現在のスパン。Messagesツールランナーでは[`anthropic.messages.tool_runner`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-tool-runner)スパンです。現在のスパンがない場合、親はありません。

* **APIスパンの親：**

  * **Messages API：** APIがツールを実行するリクエストの[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパン。
  * **Managed Agents：** ツールが実行されるターンの[`anthropic.session.turn`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)スパン。[`user.tool_confirmation`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_user_tool_confirmation_event)イベントを待機するツール使用の場合は、その確認によって開始されるターンです。
  * 別のツールが実行するコードからのツール使用の場合は、そのツールのツールスパン。Messages APIでは、そのツールは[コード実行ツール](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/code-execution-tool)です。

* **SDKスパンの子：** ツールのコードが開始するスパン。

* **APIスパンの子：** このツールが実行するコードからの各ツール使用のツールスパン。たとえば、コード実行ツールが実行するコードは`web_search`を使用する場合があります。

スパン名の接頭辞は、ツールの種類によって異なります。

* `anthropic.tool_use <tool>`は、Messages APIでの[サーバーツール](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/server-tools)の各使用、またはManaged Agentsのエージェントツールセットのツールの各使用のスパンです。エージェントツールセットのツールはAPIが実行しますが、[セルフホスト型サンドボックス](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#trace-a-self-hosted-sandbox)では環境ワーカーが実行します。
* `anthropic.mcp_tool_use <tool>` は、SDK、Messages API、およびManaged AgentsでのMCPツールの各使用のスパンです。SDKでは、[Messagesツールランナー](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-runner)または[セッションツールランナー](https://platform.claude.com/docs/ja/managed-agents/self-hosted-sandboxes-reference#session-tool-runner)が実行するMCPヘルパーのツールです。Messages APIでは、ツールは[MCPコネクター](https://platform.claude.com/docs/ja/agents-and-tools/mcp-connector)から提供されます。Managed Agentsでは、[MCPサーバーへの接続が失敗した](https://platform.claude.com/docs/ja/managed-agents/mcp-connector#handle-connection-and-authentication-failures)場合、スパン名にツール名は含まれません。
* `anthropic.custom_tool_use <tool>` は、アプリケーションが定義し、ツールランナーが実行するツールの各使用のスパンです。このスパンを出力するのはSDKのみです。

APIは次の場合にツールスパンを出力しません。

* モデルが、[カスタムツール](https://platform.claude.com/docs/ja/managed-agents/tools)など、アプリケーションが実行するツールの使用を要求した場合。SDKのツールランナーがツールを実行する場合は、ツールランナーがそのスパンを出力します。
* **Managed Agents：** エージェントがセルフホスト型サンドボックスで実行されるツールを使用した場合。ツールを実行するSDK内のワーカーがそのスパンを出力します。[セルフホスト型サンドボックスのトレース方法](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#trace-a-self-hosted-sandbox)を参照してください。
* **Managed Agents：** エージェントが[マルチエージェント](https://platform.claude.com/docs/ja/managed-agents/multiagent-orchestration)ツールまたは[アドバイザーツール](https://platform.claude.com/docs/ja/managed-agents/multiagent-orchestration#give-the-session-an-advisor)を使用した場合。
* **Managed Agents：** エージェントがツールの使用を要求したものの、[`auto`権限ポリシー](https://platform.claude.com/docs/ja/managed-agents/permission-policies#let-the-server-evaluate-each-call-with-auto)のもとでサーバーがその使用を拒否した場合、またはアプリケーションが[`user.tool_confirmation`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_user_tool_confirmation_event)イベントで拒否した場合。

| 属性                                    | 型        | 説明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`               | `string` | `execute_tool`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `gen_ai.tool.name`                    | `string` | ツールの名前。たとえば`bash`です。APIスパンでは、MCPツールの名前にサーバー名は含まれません。Managed Agentsでは、MCPサーバーへの接続が失敗した場合、モデルが生成した名前になり、コンテンツモードのスパンにのみ存在します。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `gen_ai.tool.call.id`                 | `string` | **Messages API：** モデルがツールの使用を要求したブロックの`id`。[`tool_use`](https://platform.claude.com/docs/ja/api/messages#tool_use_block)、[`server_tool_use`](https://platform.claude.com/docs/ja/api/messages#server_tool_use_block)、または[`mcp_tool_use`](https://platform.claude.com/docs/ja/api/beta/messages#beta_mcp_tool_use_block)ブロックです。<br />**Managed Agents：** エージェントがツールの使用を要求したイベントのID。[`agent.tool_use`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_agent_tool_use_event)、[`agent.mcp_tool_use`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_agent_mcp_tool_use_event)、または[`agent.custom_tool_use`](https://platform.claude.com/docs/ja/api/beta/sessions/events#beta_managed_agents_agent_custom_tool_use_event)イベントです。 |
| `anthropic.mcp.server.name`           | `string` | MCPツールのAPIスパンにのみ存在します。ツールのMCPサーバーの名前です。Messages APIでは、[`mcp_tool_use`](https://platform.claude.com/docs/ja/api/beta/messages#beta_mcp_tool_use_block)ブロックの[`server_name`](https://platform.claude.com/docs/ja/api/beta/messages#beta_mcp_tool_use_block.server_name)です。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `gen_ai.conversation.id`              | `string` | [セッション属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#session-attributes)で説明されているとおりのセッションスレッドID。Messagesツールランナーでは、[`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`)オプション](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#configure-the-sdk)で渡された会話IDで、渡されていない場合は存在しません。Messages APIリクエストのAPIスパンには存在しません。                                                                                                                                                                                                                                                                                                                                                             |
| `anthropic.session.id`                | `string` | セッションのID。Messages APIやMessagesツールランナーなど、Managed Agentsセッション外でのツール使用には存在しません。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `anthropic.session.thread.id`         | `string` | セッションツールランナーのSDKスパンにのみ存在します。セッションスレッドのIDです。プライマリスレッドでのツール使用には存在しません。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `anthropic.tool.evaluated_permission` | `string` | Managed AgentsセッションでAPIが出力するスパンにのみ存在します。ツール使用に対する[権限ポリシー](https://platform.claude.com/docs/ja/managed-agents/permission-policies)の評価結果で、`allow`または`ask`です。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `error.type`                          | `string` | ツール使用が失敗した場合のエラータイプ。ツールのコードがエラーを発生させた場合、またはツールがエラー結果を返した場合は`tool_error`です。<br />**API：** Messages APIでは、サーバーツールのエラー結果は代わりにその[`error_code`](https://platform.claude.com/docs/ja/api/messages#web_search_tool_result_error.error_code)を持ちます。たとえば`max_uses_exceeded`です。Managed Agentsでは、MCPサーバーへの接続が失敗した場合、認証が失敗したときは`mcp_authentication_failed_error`、それ以外は`mcp_connection_failed_error`です。ツール使用中にリクエストが失敗した場合は、リクエストの[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)です。                                                                                                                                                                                                                                                                                                     |
| `gen_ai.tool.description`             | `string` | SDKスパンにのみ存在します。ツール定義内の説明です。説明が空の場合は存在しません。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.tool.type`                    | `string` | SDKスパンにのみ存在します。`function`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `gen_ai.tool.call.arguments`          | `string` | <Badge>Content</Badge> OpenTelemetryの[`ToolCallArguments`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-tool-call-arguments.json)スキーマに従うJSON文字列。ツール使用の[`input`](https://platform.claude.com/docs/ja/api/messages#tool_use_block)です。                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `anthropic.tool_result.content`       | `string` | <Badge>Content</Badge> コンテンツブロックの配列または1つのオブジェクトを含むJSON文字列。モデルに返されるツール結果の`content`です。エラー結果の場合も存在しますが、Managed AgentsでMCPサーバーへの接続が失敗した場合は除きます。<br />**API：** Messages APIでは、文字列の`content`は1つの[`text`](https://platform.claude.com/docs/ja/api/messages#text_block)ブロックを含む配列になります。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### `anthropic.compaction`

* **ソース：** Messages APIリクエストの場合はAPI。
* **種類：** `INTERNAL`。
* **親：** リクエストの[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパン。
* **子：** なし。

このスパンには、コンパクションの[トークン使用量属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#token-usage)があります。[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)では、コンパクションの使用量は`gen_ai.usage.*`の合計ではなく、`anthropic.usage.compaction.*`属性に含まれます。

| 属性           | 型        | 説明                                                                                                 |
| ------------ | -------- | -------------------------------------------------------------------------------------------------- |
| `error.type` | `string` | コンパクション中にリクエストが失敗した場合の、リクエストの[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)。 |

### `anthropic.session.outcome_evaluation`

* **ソース：** Managed Agentsセッションの場合はAPI。
* **種類：** `INTERNAL`。
* **親：** イテレーションを開始したターンの[`anthropic.session.turn`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)スパン。そのターンがイテレーションより前に終了した場合も同様です。
* **子：** なし。

ステータスは、結果が`interrupted`の場合は未設定となり、それ以外の結果の場合は`OK`となります。

このスパンには、[トークン使用量属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#token-usage)のうち2つ、`gen_ai.usage.input_tokens`と`gen_ai.usage.output_tokens`があります。

| 属性                                                 | 型        | 説明                                                                                          |
| -------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------- |
| `anthropic.session.outcome.id`                     | `string` | イテレーションが評価するアウトカムのID。                                                                       |
| `anthropic.session.outcome_evaluation.result`      | `string` | イテレーションの結果：`satisfied`、`needs_revision`、`max_iterations_reached`、`failed`、または`interrupted`。 |
| `anthropic.session.outcome_evaluation.iteration`   | `int`    | イテレーション番号。                                                                                  |
| `anthropic.session.outcome_evaluation.explanation` | `string` | <Badge>Content</Badge> グレーダーによる結果の説明（プレーンテキスト）。                                             |

### `anthropic.messages.tool_runner`

* **ソース：** SDK。
* **種類：** `INTERNAL`。
* **親：** ループ開始時にアプリケーションで現在アクティブなスパン。現在アクティブなスパンがない場合はなし。
* **子：** ループ内の各リクエストの[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパンと、ランナーが実行する各ツール使用の[ツールスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)。

このスパンはループとともに終了します。アプリケーションがランナーを停止した場合、ステータスは未設定となります。ツールのコードがエラーを発生させた場合、そのツールスパンのステータスは`ERROR`となり、ループは継続します。このスパンには使用量属性がないため、使用量は子の[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)から読み取ってください。

| 属性                       | 型        | 説明                                                                                                                                                                                                                                                           |
| ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gen_ai.operation.name`  | `string` | `invoke_agent`                                                                                                                                                                                                                                               |
| `gen_ai.request.model`   | `string` | ループ内の最初のリクエストのモデル。                                                                                                                                                                                                                                           |
| `gen_ai.conversation.id` | `string` | [`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`)オプション](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#configure-the-sdk)で渡された会話ID。指定がない場合は存在しません。 |
| `error.type`             | `string` | ループが失敗した場合の、ループを終了させたリクエストの[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)。ランナー自体が失敗した場合は`client_error`。                                                                                                                                |
| `gen_ai.output.type`     | `string` | リクエストが出力形式をJSONに設定している場合は`json`。それ以外の場合は存在しません。                                                                                                                                                                                                              |

### `anthropic.messages.batches.<method>`

* **ソース：** すべてのMessage BatchesメソッドについてはSDK。
* **種類：** `CLIENT`。
* **親：** アプリケーションがメソッドを呼び出す時点で現在アクティブなスパン。現在アクティブなスパンがない場合はなし。
* **子：** なし。

これらのスパンには、すべての[リクエストのSDKスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-resources-method)の属性もあります。

| 属性                                      | 型        | 説明                                                                                                               |
| --------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------- |
| `anthropic.message.batch.id`            | `string` | メソッドが対象とするバッチのID。`create`の場合は新しいバッチのID。`list`および失敗した`create`では存在しません。                                            |
| `anthropic.message.batch.request_count` | `int`    | `create`のみ。[`requests`](https://platform.claude.com/docs/ja/api/messages/batches/create#create.requests)配列内の項目数。 |

### `anthropic.sessions.<method>`

* **ソース：** SDKおよびAPI。
* **種類：** SDKからは`CLIENT`、APIからは`SERVER`。
* **SDKスパンの親：** アプリケーションがメソッドを呼び出す時点で現在アクティブなスパン。現在アクティブなスパンがない場合はなし。
* **APIスパンの親：** リクエストの[`traceparent`ヘッダー](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#connect-api-spans-to-your-own-traces)内のスパン。リクエストがSDKから送信された場合はSDKスパンとなり、ヘッダーがない場合はなし。
* **SDKスパンの子：** そのリクエストに対するAPIのスパン。
* **APIスパンの子：** なし。

APIは、[Sessions API](https://platform.claude.com/docs/ja/managed-agents/sessions)のエンドポイントへの認証済みリクエストごとに`anthropic.sessions.<method>`スパンを出力します。Claude Consoleで送信されたメッセージや、[スケジュールされたデプロイメント](https://platform.claude.com/docs/ja/managed-agents/scheduled-deployments)が開始するセッションなど、プラットフォームがユーザーに代わって送信するリクエストにもスパンがあり、それぞれ新しいトレース内に作成されます。

<Accordion title="スパン名とエンドポイント">
  | スパン                                        | エンドポイント                                                                                                                                   |
  | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
  | `anthropic.sessions.create`                | [`POST /v1/sessions`](https://platform.claude.com/docs/ja/api/beta/sessions/create)                                                       |
  | `anthropic.sessions.list`                  | [`GET /v1/sessions`](https://platform.claude.com/docs/ja/api/beta/sessions/list)                                                          |
  | `anthropic.sessions.retrieve`              | [`GET /v1/sessions/{session_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/retrieve)                                         |
  | `anthropic.sessions.update`                | [`POST /v1/sessions/{session_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/update)                                          |
  | `anthropic.sessions.delete`                | [`DELETE /v1/sessions/{session_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/delete)                                        |
  | `anthropic.sessions.archive`               | [`POST /v1/sessions/{session_id}/archive`](https://platform.claude.com/docs/ja/api/beta/sessions/archive)                                 |
  | `anthropic.sessions.events.send`           | [`POST /v1/sessions/{session_id}/events`](https://platform.claude.com/docs/ja/api/beta/sessions/events/send)                              |
  | `anthropic.sessions.events.list`           | [`GET /v1/sessions/{session_id}/events`](https://platform.claude.com/docs/ja/api/beta/sessions/events/list)                               |
  | `anthropic.sessions.events.stream`         | [`GET /v1/sessions/{session_id}/events/stream`](https://platform.claude.com/docs/ja/api/beta/sessions/events/stream)                      |
  | `anthropic.sessions.resources.add`         | [`POST /v1/sessions/{session_id}/resources`](https://platform.claude.com/docs/ja/api/beta/sessions/resources/add)                         |
  | `anthropic.sessions.resources.list`        | [`GET /v1/sessions/{session_id}/resources`](https://platform.claude.com/docs/ja/api/beta/sessions/resources/list)                         |
  | `anthropic.sessions.resources.retrieve`    | [`GET /v1/sessions/{session_id}/resources/{resource_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/resources/retrieve)       |
  | `anthropic.sessions.resources.update`      | [`POST /v1/sessions/{session_id}/resources/{resource_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/resources/update)        |
  | `anthropic.sessions.resources.delete`      | [`DELETE /v1/sessions/{session_id}/resources/{resource_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/resources/delete)      |
  | `anthropic.sessions.threads.list`          | [`GET /v1/sessions/{session_id}/threads`](https://platform.claude.com/docs/ja/api/beta/sessions/threads/list)                             |
  | `anthropic.sessions.threads.retrieve`      | [`GET /v1/sessions/{session_id}/threads/{thread_id}`](https://platform.claude.com/docs/ja/api/beta/sessions/threads/retrieve)             |
  | `anthropic.sessions.threads.archive`       | [`POST /v1/sessions/{session_id}/threads/{thread_id}/archive`](https://platform.claude.com/docs/ja/api/beta/sessions/threads/archive)     |
  | `anthropic.sessions.threads.events.list`   | [`GET /v1/sessions/{session_id}/threads/{thread_id}/events`](https://platform.claude.com/docs/ja/api/beta/sessions/threads/events/list)   |
  | `anthropic.sessions.threads.events.stream` | [`GET /v1/sessions/{session_id}/threads/{thread_id}/stream`](https://platform.claude.com/docs/ja/api/beta/sessions/threads/events/stream) |
</Accordion>

このスパンには[セッション属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#session-attributes)があります。SDKスパンには、すべての[リクエストのSDKスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-resources-method)の属性もあります。

| 属性           | 型        | 説明                                                                                                                                                                                                                                                                                                                |
| ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `error.type` | `string` | 失敗したリクエストの[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)。例：`rate_limit_error`。<br />**SDK：** [リクエストのSDKスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-resources-method)のその他の値も含みます。<br />**API：** APIがエラーレスポンスなしで接続を閉じた場合、またはAPIの障害によりストリームが終了した場合は`api_error`。 |

### `anthropic.environment.work`

* **ソース：** CLI、およびPython、TypeScript、GoのSDK。
* **種類：** `INTERNAL`。
* **親：** 環境ワーカーまたはワークポーラーがワークアイテムを取得する時点でアプリケーションで現在アクティブなスパン。現在アクティブなスパンがない場合はなし。`ant beta:worker poll`では、このスパンはルートスパンです。
* **子：** 環境ワーカーがワークアイテムを処理する間に送信するリクエストのスパンと、ワークアイテムのために実行する各ツールの[ツールスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)。

環境ワーカーとワークポーラーは、セルフホスト型サンドボックスでワークアイテムを取得する[SDKヘルパー](https://platform.claude.com/docs/ja/managed-agents/self-hosted-sandboxes#sdk-helpers)です。これらは、ポーリングがワークアイテムを返した時点からその処理が終了するまで、ワークアイテムごとに1つの`anthropic.environment.work`スパンを出力します。

| 属性                              | 型        | 説明                                                                       |
| ------------------------------- | -------- | ------------------------------------------------------------------------ |
| `anthropic.environment.id`      | `string` | 環境のID。                                                                   |
| `anthropic.environment.work.id` | `string` | ワークアイテムのID。                                                              |
| `anthropic.session.id`          | `string` | ワークアイテムが属するセッションのID。                                                     |
| `error.type`                    | `string` | リクエストによって処理が終了した場合の、失敗したリクエストのスパンの`error.type`。その他の失敗の場合は`client_error`。 |

### `anthropic.<resources>.<method>`

* **ソース：** SDK。
* **種類：** `CLIENT`。
* **親：** アプリケーションがメソッドを呼び出す時点で現在アクティブなスパン。現在アクティブなスパンがない場合はなし。
* **子：** なし。

リクエストを送信し、このページにセクションがない各SDKメソッドは、`anthropic.<resources>.<method>`スパンを出力します。例：`anthropic.models.list`や`anthropic.files.upload`。リストの後続ページごとのリクエストには、それぞれ独自のスパンがあります。

スパンはリトライを含むリクエスト全体をカバーし、SDKが値を持っている場合は、同じ名前のAPIのスパンの各属性を持ちます。SDKはスパンの開始時に`http.request.method`と`http.route`を設定するため、サンプラーはそれらを使用できます。

[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)、[`anthropic.messages.count_tokens`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-count-tokens)、[`anthropic.messages.batches.<method>`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-batches-method)を含む、すべてのリクエストに対するSDKスパンには、次の属性があります：

| 属性                          | 型        | 説明                                                                                                                                                                                                                                                                                                                                                                                                           |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gen_ai.conversation.id`    | `string` | [`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`)オプション](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#configure-the-sdk)で渡された会話ID。指定がない場合、[セッション属性](https://platform.claude.com/docs/ja/api/opentelemetry/spans#session-attributes)に記載されているManaged AgentsリクエストではセッションスレッドIDとなり、その他のリクエストでは存在しません。 |
| `anthropic.<resource>.id`   | `string` | リクエストのパス内の各IDにつき1つの属性と、メソッドが作成するオブジェクトのIDにつき1つの属性。名前はパスから単数形で取られます。例：`anthropic.session.id`や`anthropic.session.thread.id`。                                                                                                                                                                                                                                                                                   |
| `gen_ai.agent.id`           | `string` | エージェントメソッドにおける、エージェントのID。                                                                                                                                                                                                                                                                                                                                                                                    |
| `gen_ai.memory.store.id`    | `string` | メモリストアメソッドにおける、メモリストアのID。                                                                                                                                                                                                                                                                                                                                                                                    |
| `gen_ai.memory.record.id`   | `string` | メモリメソッドにおける、メモリのID。                                                                                                                                                                                                                                                                                                                                                                                          |
| `http.request.resend_count` | `int`    | リトライなど、何らかの理由でSDKがリクエストを再送信した回数。SDKが再送信しなかった場合は存在しません。                                                                                                                                                                                                                                                                                                                                                       |
| `error.type`                | `string` | 失敗した呼び出しの[エラータイプ](https://platform.claude.com/docs/ja/api/errors#http-errors)。例：`rate_limit_error`。エラーレスポンスにエラータイプがない場合はHTTPステータスコード（例：`502`）。SDK内で呼び出しが失敗した場合は`connection_error`、`client_timeout_error`、または`client_error`。サーバーがストリームを早期に終了した場合は`api_error`。                                                                                                                                                 |
| `server.address`            | `string` | クライアントのベースURLのホスト。デフォルトは`api.anthropic.com`。クラウドプラットフォームのクライアントでは、そのプラットフォームのホスト。                                                                                                                                                                                                                                                                                                                            |
| `url.query`                 | `string` | エンドポイントが定義するクエリパラメータのみを含む、URLのクエリ文字列。該当するものがない場合は存在しません。メタデータのみモードでは、クエリに`email`などの機密パラメータが含まれる場合は存在しません。                                                                                                                                                                                                                                                                                                    |
| `url.full`                  | `string` | `url.scheme`、`server.address`、ベースURLにポートがある場合はそのポート、`url.path`、`url.query`から構成されるURL。メタデータのみモードでは、そのモードが`url.query`を除外する場合は常に存在しません。                                                                                                                                                                                                                                                                         |
