---
title: Claude APIのOpenTelemetry
url: https://platform.claude.com/docs/ja/manage-claude/opentelemetry
description: Claude SDKとClaude APIから出力されるOpenTelemetryスパンを使用して、Messages APIリクエスト、ツール使用、Managed Agentsセッションをトレースします。
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 APIとSDKは、Messages APIリクエスト、ツール使用、Managed Agentsセッションを[OpenTelemetry](https://opentelemetry.io/)でトレースできます。これらのトレースは、すでにお使いのオブザーバビリティプラットフォームで確認できます。失敗したリクエストや遅いリクエストのデバッグ、トークン消費量とレイテンシの追跡、実際のトラフィックからの評価の構築に活用してください。また、アプリケーション自体のトレース内で各リクエストを確認し、それを送信したユーザーや機能と関連付けることもできます。

OpenTelemetryは、ほとんどのオブザーバビリティプラットフォームがサポートしているベンダー中立の標準です。「*trace*」（トレース）とは、システム内を通過する1つのリクエストの完全な記録です。「*span*」（スパン）とは、モデルリクエストやツール使用など、トレース内の1つのステップです。APIとSDKは[GenAIセマンティック規約](https://github.com/open-telemetry/semantic-conventions-genai)の属性を使用するため、この規約をサポートするプラットフォームは追加の設定なしでスパンを認識できます。

## はじめに

SDKトレーシング、APIトレーシング、またはその両方を設定できます。[トレースの例](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#example-traces-and-how-to-read-them)のように、リクエストのSDKスパンとAPIスパンを1つのトレースで確認するには、両方を設定してください。Claude Platform on AWSへのリクエストの場合、APIスパンは代わりに独自のトレースに含まれます。

<CardGroup cols={3}>
  <Card title="SDKトレースを設定する" icon="code-brackets" href="https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk" layout="horizontal">
    SDKをインストールし、トレーサープロバイダーを登録します。
  </Card>

  <Card title="APIトレースを設定する" icon="cloud" href="https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api" layout="horizontal">
    Claude Consoleで宛先を追加します。
  </Card>

  <Card title="スパンリファレンス" icon="book" href="https://platform.claude.com/docs/ja/api/opentelemetry/spans" layout="horizontal">
    スパンとその属性を調べられます。
  </Card>
</CardGroup>

| 得られるもの                                                                                                                 | SDKトレース                                                                    | APIトレース                                                                                  | 両方を併用                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [Messages API](https://platform.claude.com/docs/ja/api/messages/create)リクエスト                                           | ✅                                                                          | ✅                                                                                        | ✅                                                                                        |
| [Sessions API](https://platform.claude.com/docs/ja/managed-agents/sessions)リクエスト                                       | ✅                                                                          | ✅                                                                                        | ✅                                                                                        |
| [トークン使用量](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#count-tokens)                                | ✅                                                                          | ✅                                                                                        | ✅                                                                                        |
| リクエスト内の各モデル実行                                                                                                          | —                                                                          | ✅                                                                                        | ✅                                                                                        |
| [Managed Agents](https://platform.claude.com/docs/ja/managed-agents/overview)のターン                                      | —                                                                          | ✅                                                                                        | ✅                                                                                        |
| APIが実行する[サーバーツール](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/server-tools)                          | —                                                                          | ✅                                                                                        | ✅                                                                                        |
| [ツールランナー](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-runner)が実行するクライアントツール                     | ✅                                                                          | —                                                                                        | ✅                                                                                        |
| [セルフホスト型サンドボックス](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#trace-a-self-hosted-sandbox)内のツール | ✅                                                                          | —                                                                                        | ✅                                                                                        |
| ファイルのアップロードなど、その他のAPIリクエスト                                                                                             | ✅                                                                          | —                                                                                        | ✅                                                                                        |
| 設定                                                                                                                     | [コード](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk) | [Console](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api)           | 両方                                                                                       |
| 必要な権限                                                                                                                  | なし                                                                         | [管理者](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#what-you-need) | [管理者](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#what-you-need) |
| 対象                                                                                                                     | SDKを使用するクライアント                                                             | すべてのクライアント                                                                               | すべてのクライアント                                                                               |
| クラウドプラットフォームのサポート                                                                                                      | すべて                                                                        | Claude Platform<br />Claude Platform on AWS                                              | Claude Platform<br />Claude Platform on AWS                                              |

Claude Code、Agent SDK、またはCoworkについては、[Claude Codeのモニタリング](https://code.claude.com/docs/en/monitoring-usage)、[Agent SDKのオブザーバビリティ](https://code.claude.com/docs/en/agent-sdk/observability)、または[Coworkのアクティビティモニタリング](https://support.claude.com/en/articles/14477985-monitor-claude-cowork-activity-with-opentelemetry)を参照してください。

## パートナープラットフォームにトレースを送信する

トレースは、以下のパートナーを含め、OTLP を受け付けるあらゆるオブザーバビリティプラットフォームに送信できます。

<CardGroup cols={3}>
  <Card title="Arize AI" image="https://platform.claude.com/docs/images/partner-logos/arize.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/arize-dark.svg" imageOffsetLeft={2} href="https://arize.com/docs/ax/integrations/platforms/claude-managed-agents/claude-managed-agents-tracing">
    AIのための統合オブザーバビリティおよび評価プラットフォーム。
  </Card>

  <Card title="Braintrust" image="https://platform.claude.com/docs/images/partner-logos/braintrust.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/braintrust-dark.svg" imageHeight={25} imageOffsetLeft={1} href="https://www.braintrust.dev/docs/integrations/ai-providers/anthropic#export-opentelemetry-traces-from-the-claude-api">
    エージェントのためのアクティブなオブザーバビリティプラットフォーム。
  </Card>

  <Card title="Databricks" image="https://platform.claude.com/docs/images/partner-logos/databricks.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/databricks-dark.svg" imageHeight={26} imageOffsetLeft={1} href="https://docs.databricks.com/aws/en/ai-gateway/unified-trace-table">
    オブザーバビリティおよび評価のための統合AIコントロールプレーン。
  </Card>

  <Card title="Datadog" image="https://platform.claude.com/docs/images/partner-logos/datadog.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/datadog-dark.svg" imageHeight={28} imageOffsetLeft={2} href="https://docs.datadoghq.com/llm_observability/instrument/otel_instrumentation/?tab=python#using-claude-managed-agents">
    AIを活用したオブザーバビリティとセキュリティ。
  </Card>

  <Card title="Grafana Cloud" image="https://platform.claude.com/docs/images/partner-logos/grafana.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/grafana-dark.svg" imageHeight={34} imageOffsetLeft={2} href="https://grafana.com/docs/grafana-cloud/observe-and-act/agent-observability/guides/send-claude-platform-traces/">
    フルマネージドのオープンなオブザーバビリティプラットフォーム。
  </Card>

  <Card title="Honeycomb" image="https://platform.claude.com/docs/images/partner-logos/honeycomb.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/honeycomb-dark.svg" imageHeight={36} imageOffsetLeft={4} href="https://docs.honeycomb.io/send-data/use-cases/claude-platform">
    新しい形のソフトウェアのためのオブザーバビリティプラットフォーム。
  </Card>

  <Card title="Langfuse" image="https://platform.claude.com/docs/images/partner-logos/langfuse.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/langfuse-dark.svg" imageHeight={26} imageOffsetLeft={1} href="https://langfuse.com/integrations/model-providers/claude-platform">
    オープンソースのエージェントオブザーバビリティおよび評価プラットフォーム。
  </Card>

  <Card title="LangSmith" image="https://platform.claude.com/docs/images/partner-logos/langchain.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/langchain-dark.svg" imageHeight={29} href="https://docs.langchain.com/langsmith/trace-anthropic">
    LangSmithエージェントエンジニアリングプラットフォーム。
  </Card>

  <Card title="New Relic" image="https://platform.claude.com/docs/images/partner-logos/new-relic.svg" imageHeight={27} imageOffsetLeft={1} href="https://docs.newrelic.com/docs/ai-monitoring/opentelemetry-ai-monitoring/#anthropic">
    インテリジェントなオブザーバビリティプラットフォーム。
  </Card>

  <Card title="PostHog" image="https://platform.claude.com/docs/images/partner-logos/posthog.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/posthog-dark.svg" imageHeight={29} href="https://posthog.com/docs/ai-observability/installation/anthropic?tab=Claude+Platform&utm_source=anthropic&utm_campaign=anthropic-otel">
    成功するプロダクトを構築するためのオールインワンプラットフォーム。
  </Card>

  <Card title="Sentry" image="https://platform.claude.com/docs/images/partner-logos/sentry.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/sentry-dark.svg" imageHeight={25} href="https://sentry.io/cookbook/trace-claude-platform-with-opentelemetry/">
    壊れたコードや誤動作するエージェントをデバッグしましょう。
  </Card>

  <Card title="Splunk" image="https://platform.claude.com/docs/images/partner-logos/splunk.svg" imageDark="https://platform.claude.com/docs/images/partner-logos/splunk-dark.svg" imageHeight={27} imageOffsetLeft={1} href="https://agent-observability-docs.splunk.com/sdk-api/third-party-integrations/claude">
    エージェントを観測、評価、保護しましょう。
  </Card>
</CardGroup>

## コンテンツモード

各宛先と各SDKクライアントにはコンテンツモードがあり、スパンにモデルのプロンプトとレスポンスを含めるかどうかを設定します。[宛先を追加する](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#add-a-destination)とき、または[SDKを設定する](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/sdk#configure-the-sdk)ときに設定します。

* **Metadata only**（SDKでは`metadata_only`）：デフォルトです。スパンには識別子、タイミング、ステータス、トークン数、およびエージェントやツールの名前と説明、MCPサーバーの名前など、ご自身で指定したテキストが含まれます。
* **Full content**（SDKでは`content`）：最も高い可視性が得られます。スパンにはモデルのプロンプトとレスポンス、およびMetadata onlyのすべての内容が含まれます。

Full contentを使用すると、実行が失敗した理由や遅かった理由の確認、会話全体の閲覧、実際のトレースからの評価の構築も可能です。[OpenTelemetryスパンリファレンス](https://platform.claude.com/docs/ja/api/opentelemetry/spans)では、プロンプトとレスポンスを保持する属性に<Badge>Content</Badge>タグが付いています。

<Info>
  オブザーバビリティプラットフォームはこのコンテンツを独自のアクセス設定と保持設定のもとで保存するため、それらが組織の要件を満たしていることを確認してください。
</Info>

組織にAnthropicとのHIPAA、FERPA、またはK-12のデータ取り扱い制限がある場合、宛先はコンテンツモードにかかわらずメタデータのみをエクスポートします。SDKスパンは影響を受けません。

[ゼロデータ保持](https://platform.claude.com/docs/ja/manage-claude/api-and-data-retention)を利用している場合でも、Full contentを使用できます。Messages APIリクエストについては、APIはエクスポートされたコンテンツを、宛先に配信するまでメモリ内にのみ保持します。[Claude Managed Agents](https://platform.claude.com/docs/ja/managed-agents/overview)はゼロデータ保持の対象外であり、OpenTelemetryを使用してもそのデータ保持は変わりません。

### コンテンツの制限

Full contentでは、デフォルトで各スパンに最大0.75 MBのコンテンツを含められます。この制限には、200kトークンのコンテキストウィンドウを英語のテキストで埋めた内容が収まり、また多くのオブザーバビリティプラットフォームやプロキシの1 MBのリクエスト制限を下回ります。**Provider**としてパートナープラットフォームを選択した場合、Consoleはそのプラットフォームが受け付ける制限を設定します。

コンテンツが制限を超えると、SDKまたはAPIはそのコンテンツを短縮し、`anthropic.content.truncated`を`true`に設定します。リクエストのスパンでは、まずシステムプロンプトと最も古いメッセージが削除され、ツールスパンでは、結果の末尾からブロック単位で削除されます。画像とドキュメントは、そのタイプのみが表示されます。

次の場合は制限を変更します。

* **オブザーバビリティプラットフォームがより大きなペイロードを受け付ける場合：** 制限を引き上げるか撤廃して、長いプロンプトとレスポンスを短縮せずに保持します。1Mトークンのコンテキストウィンドウ全体には約4 MBが必要です。
* **オブザーバビリティプラットフォームまたはその前段にあるプロキシが大きなリクエストを拒否する場合：** 制限を引き下げます。

SDKでは、`traces.max_content_bytes` (typescript, java, php: `traces.maxContentBytes`; csharp: `Traces.MaxContentBytes`; go: `option.WithOpenTelemetryTracesMaxContentBytes()`)を設定します。Consoleでは、[宛先を追加](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#add-a-destination)する際に**Content mode**を**Full content**に設定し、**Advanced settings**で**Maximum content size in MB**を設定します。

## トレースの例と読み方

### Messages APIリクエスト

[メッセージを作成する](https://platform.claude.com/docs/ja/api/messages/create)リクエストのAPIスパンの下に、APIは各モデルリクエストのスパンと、APIが実行するサーバーツールまたはMCPコネクタツールの各使用についてのツールスパンを追加します。

この例では、アプリケーションが[ツールランナー](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-runner)を呼び出します。ツールランナーは、ツールを実行してその結果をClaudeに送り返すSDKヘルパーです。ツールランナーが送信する各リクエストには、SDKからのクライアントスパンとAPIからのサーバースパンがあります。スパンは次の順序で表示されます：

1. アプリケーションが`answer_question`スパンを開始し、その内側でMessagesツールランナーを呼び出します（[`anthropic.messages.tool_runner`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-tool-runner)スパンとして表示されます）。
2. ツールランナーが最初のリクエストを送信します（最初の[`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)クライアントスパンとその下のスパンとして表示されます）。このリクエストでは、APIが2つのモデルリクエストの間でウェブ検索ツールを実行します。
3. 2番目のモデルリクエストで、モデルがカスタムの`get_weather`ツールの使用を要求するため、最初のリクエストが終了します。
4. ツールランナーが`get_weather`を実行します（`anthropic.custom_tool_use get_weather`スパンとして表示されます）。
5. ツールランナーがツールの結果とともに2番目のリクエストを送信します（2番目の`anthropic.messages.create`クライアントスパンとその下のスパンとして表示されます）。
6. 2番目のリクエストで、モデルが最終的な回答を返します。

![Messagesツールランナーのトレース例：クライアントスパンとサーバースパン、モデルリクエスト、web\_search、get\_weatherを含む2つのリクエスト](https://platform.claude.com/docs/images/opentelemetry-sdk-trace-shape.svg)

アプリケーション内のSDKは、[`anthropic.messages.tool_runner`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-tool-runner)スパン、[`anthropic.custom_tool_use`](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/manage-claude/opentelemetry/sdk)してください。

各リクエストのトークン使用量は、そのリクエストの複数のスパンに記録されます。各トークンを1回だけカウントするには、[トークンのカウント](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#count-tokens)を参照してください。

[Full content](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#choose-a-content-mode)では、`anthropic.messages.create`サーバースパンにプロンプトとレスポンスが含まれます。システムプロンプトは`gen_ai.system_instructions`に、リクエストのメッセージは`gen_ai.input.messages`に、レスポンスは`gen_ai.output.messages`に含まれます。

各スパンとその属性については、[OpenTelemetryスパンリファレンス](https://platform.claude.com/docs/ja/api/opentelemetry/spans)を参照してください。

### Managed Agentsのセッション

セッションには、Sessions APIリクエストごとの「span」（スパン）と、エージェントのターンごとのターンスパンがあります。リクエストによって開始されたターンは、そのリクエストのスパンの子になります。ターンには、モデルリクエストごとのスパンと、APIが実行するツールごとのスパンが含まれます。ただし、[ツールスパンのリファレンスに記載されているケース](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)は除きます。また、結果評価ごとのスパンも含まれます。

この例では、アプリケーションがセッションにメッセージを送信し、カスタムツールを実行する1つのチャットリクエストを追跡します。「trace」（トレース）には、アプリケーションとAPIの両方からのスパンが、次の順序で含まれます。

1. アプリケーションがユーザーから`POST /chat`リクエストを受け取ります。
2. アプリケーションがSDKのセッションツールランナーを開始し、セッションのイベントを一覧表示してストリーミングします（`anthropic.sessions.events.stream`スパンと`anthropic.sessions.events.list`スパンとして表示されます）。
3. アプリケーションが`sessions.events.send`を呼び出して、ユーザーのメッセージをセッションに送信します。
4. ターンが開始され、モデルリクエスト、`bash`ツール使用、および別のスレッドでのターンが含まれます（最初の`anthropic.session.turn`スパンとその配下のスパンとして表示されます）。
5. モデルが[カスタムツール](https://platform.claude.com/docs/ja/managed-agents/tools)`list_issues`の使用を要求するため、ターンは停止理由`requires_action`で終了します。
6. セッションツールランナーが`list_issues`を実行し（`anthropic.custom_tool_use list_issues`スパンとして表示されます）、`sessions.events.send`を呼び出してその結果を送信します。
7. ツールの結果とともに2番目のターンが開始されます（最後の`anthropic.session.turn`スパンとして表示されます）。

![Managed Agentsセッションのトレース例：POST /chatスパン、セッションツールランナーのイベントストリームおよびイベント一覧リクエスト、ユーザーメッセージを送信するリクエストのクライアントスパンとサーバースパン、モデルリクエスト・bashツールの使用・別スレッドでのターンを含むターン、list\_issuesを実行するランナー、ツールの結果を送信するリクエストのクライアントスパンとサーバースパン、および2番目のターン。](https://platform.claude.com/docs/images/opentelemetry-trace-shape.svg)

アプリケーション内のSDKは、[`anthropic.custom_tool_use`](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/manage-claude/opentelemetry/sdk)してください。

セッションのスパンは、複数のトレースにまたがる場合があります。たとえば、新しいルートトレースから後続のリクエストを送信した場合です。[マルチエージェント](https://platform.claude.com/docs/ja/managed-agents/multiagent-orchestration)を有効にすると、セッションは複数のスレッドを持つこともできます。必要なスパンを見つけるには、IDでグループ化します。

* **1つのスレッド：** セッションスレッドIDを保持する`gen_ai.conversation.id`でスパンをグループ化します。開始時刻で並べ替えると、スレッドをトランスクリプトとして読むことができます。
* **すべてのスレッドを含むセッション全体：** トレースをまたいで`anthropic.session.id`でスパンをグループ化します。

[Full content](https://platform.claude.com/docs/ja/manage-claude/opentelemetry#choose-a-content-mode)を使用すると、セッションのスパンからその内容を読むことができます。

* ターンの内容を読むには、その[ターンスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-turn)を使用します。システムプロンプトはスレッドの最初のターンスパンの`gen_ai.system_instructions`に、入力は`gen_ai.input.messages`（あなたのメッセージとツールの結果、`system.message`イベント、および他のスレッドからのメッセージ）に、出力は`gen_ai.output.messages`（エージェントのメッセージ、ツール使用、およびツールの結果）に含まれます。
* ツール使用の引数と結果を確認するには、その[ツールスパン](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use)を読みます。引数は`gen_ai.tool.call.arguments`に、結果は`anthropic.tool_result.content`に含まれます。

各スパンとその属性については、[OpenTelemetryスパンリファレンス](https://platform.claude.com/docs/ja/api/opentelemetry/spans)を参照してください。

## トークンのカウント

各トークンを1回だけカウントするには、リクエストごとに1つのソースのスパンのみを合計します。Messages APIリクエストにSDKスパンとAPIスパンの両方がある場合は、そのAPIスパンを合計します。どちらも`anthropic.messages.create`という名前なので、種類（kind）で区別します。SDKスパンは`CLIENT`で、その子であるAPIスパンは`SERVER`です。

一部の使用量属性はAPIスパンの複数のレベルで重複するため、各ソースについて次のスパンのみを合計してください。

* **SDKスパン：** [`anthropic.messages.create`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-messages-create)スパンを合計します。リクエストに[コンパクション](https://platform.claude.com/docs/ja/build-with-claude/compaction)がある場合は、`gen_ai.usage.*`属性にコンパクションのトークンが含まれないため、スパンの`anthropic.usage.compaction.input_tokens`と`anthropic.usage.compaction.output_tokens`も加算します。[フォールバックモデル](https://platform.claude.com/docs/ja/build-with-claude/refusals-and-fallback)がリクエストを処理した場合、そのスパンにはレスポンスを処理したモデルの使用量のみが含まれます。
* **Messages APIリクエストのAPIスパン：** [`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.messages.create`スパンの`anthropic.usage.compaction.*`属性は同じトークンを保持しているため、これらを追加で加算しないでください。
* **Managed AgentsセッションのAPIスパン：** `anthropic.model_request`スパンと[`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/ja/api/opentelemetry/spans#anthropic-session-outcome-evaluation)スパンを合計します。

たとえば配信が再試行された場合など、スパンが複数回届くことがあります。オブザーバビリティプラットフォームで重複が除去されない場合は、トレースIDとスパンIDによって各スパンを1回だけカウントしてください。

`gen_ai.usage.input_tokens`には、プロンプトキャッシングのキャッシュから読み取られたトークンとキャッシュに書き込まれたトークンがすでに含まれているため、キャッシュ属性を加算しないでください。すべての使用量属性については、[トークン使用量](https://platform.claude.com/docs/ja/api/opentelemetry/spans#token-usage)を参照してください。

<Note>
  エクスポートされたスパンは、API使用量の完全な記録であることが保証されているわけではありません。スパンの配信は[ベストエフォート](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#delivery-and-health)であるため、スパンが失われる場合があります。また、呼び出し元は、リクエストの[`traceparent`ヘッダー](https://platform.claude.com/docs/ja/manage-claude/opentelemetry/api#connect-api-spans-to-your-own-traces)内のsampledフラグをオフにすることで、そのリクエストのスパンを除外することもできます。漏洩したキーを見つけるなど、各APIキーの使用量を追跡するには、[Usage API](https://platform.claude.com/docs/ja/manage-claude/usage-cost-api#usage-api)を使用します。これは、スパンのないリクエストの使用量も集計します。
</Note>
