---
title: OpenTelemetry span reference
url: https://platform.claude.com/docs/en/api/opentelemetry/spans
description: The OpenTelemetry spans and span attributes that the Claude API and the Claude SDK emit.
featureMetadata:
  topic:
    title: OpenTelemetry
    url: https://platform.claude.com/docs/en/manage-claude/opentelemetry
  status: beta
---

<Note>
  OpenTelemetry export is in beta. It's provided under your agreement with Anthropic, including the Beta Services section of the [Service Specific Terms](https://www.anthropic.com/legal/service-specific-terms). Span names and attributes can change during the beta.
</Note>

To set up export, see [Use OpenTelemetry with the Claude SDK](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk) and [Use OpenTelemetry with the Claude API](https://platform.claude.com/docs/en/manage-claude/opentelemetry/api).

## Span names and kinds

| Property              | SDK spans                                                                                                                              | API spans                                                |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| `service.name`        | The application's `service.name`                                                                                                       | `claude-platform`                                        |
| Instrumentation scope | `com.anthropic.sdk.<language>` or `com.anthropic.sdk.cli`, plus `.<platform>` on a cloud platform's client, with the package's version | `com.anthropic.claude-platform`                          |
| Span kind             | `CLIENT` on the span for a request, `INTERNAL` otherwise                                                                               | `SERVER` on the span for a request, `INTERNAL` otherwise |

* **Spans for requests** have the name of the request's API method: `anthropic.` followed by the method's path in the API reference, with dots instead of slashes and without `beta`. For example, `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_()`) sends a request to [send session events](https://platform.claude.com/docs/en/api/beta/sessions/events/send), and its spans have the name [`anthropic.sessions.events.send`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-events-send).
* **Tool spans** have a fixed name, a space, and the tool name, for example [`anthropic.tool_use bash`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use).

## Span status

* **`OK`:** The step completed.
* **`ERROR`:** The step failed.
* **Unset:** The application canceled the step, for example when it sent a [`user.interrupt`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_user_interrupt_event) event.

A stream's span ends when the stream ends. If the application closes the stream early, the SDK span has the status unset, so the SDK span for a stream that never completes, such as [`anthropic.sessions.events.stream`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-method), has the status unset or `ERROR`.

## Attributes

Attributes use the [OpenTelemetry semantic conventions for generative AI](https://github.com/open-telemetry/semantic-conventions-genai) (`gen_ai.*`) where one exists. Anthropic attributes start with `anthropic.`. The spans follow the conventions at commit [`e57c543b`](https://github.com/open-telemetry/semantic-conventions-genai/tree/e57c543b4889619eb2a05702471937db5119165d) of September 24, 2026. The conventions are still in development.

### Common attributes

Every span for a request has the following attributes, except where a description says otherwise. Other spans can have only the first three:

| Attribute                   | Type     | Description                                                                                                                                                                   |
| --------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.provider.name`      | `string` | `anthropic`. On every span.<br />**SDK:** `aws.bedrock` on the Amazon Bedrock clients (Mantle included), and `gcp.vertex_ai` on the client for Google Cloud's Agent Platform. |
| `anthropic.organization.id` | `string` | The organization ID.                                                                                                                                                          |
| `anthropic.workspace.id`    | `string` | The ID of the workspace that the work runs in.                                                                                                                                |
| `anthropic.request.id`      | `string` | The value of the `request-id` response header.                                                                                                                                |
| `http.request.method`       | `string` | The request's HTTP method, for example `POST`.                                                                                                                                |
| `http.route`                | `string` | The endpoint's path, with placeholders for its path parameters, for example `/v1/sessions/{session_id}`.                                                                      |
| `http.response.status_code` | `int`    | The final response's HTTP status code. For a stream, the status code sent with the headers. Absent when there was no response.                                                |
| `server.address`            | `string` | The host that the request was sent to, for example `api.anthropic.com`.                                                                                                       |
| `server.port`               | `int`    | The request URL's port, or the default port of its scheme when the URL doesn't have one.                                                                                      |
| `url.scheme`                | `string` | The URL's scheme, for example `https`.                                                                                                                                        |
| `url.path`                  | `string` | The URL's path, for example `/v1/messages`.                                                                                                                                   |
| `url.query`                 | `string` | The URL's query string, with only the query parameters that the endpoint defines. Absent when there are none.                                                                 |
| `url.full`                  | `string` | The request's URL.                                                                                                                                                            |

On Claude Platform on AWS, API spans don't have `server.address`, `server.port`, or `url.full`.

### Session attributes

In a Managed Agents session, spans have the following attributes. A session's spans can be in more than one trace, so to assemble a view of the session, such as a transcript, [group its spans by these IDs](https://platform.claude.com/docs/en/manage-claude/opentelemetry#a-managed-agents-session).

| Attribute                | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `anthropic.session.id`   | `string` | The session ID. Absent on the spans for methods that don't act on one session, such as [`anthropic.sessions.list`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-method).                                                                                                                                                                                                                                                                                    |
| `gen_ai.conversation.id` | `string` | The ID of the session thread that the span belongs to. The SDK's [`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`) option](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#configure-the-sdk) replaces it with your own conversation ID. Absent on SDK spans with no thread unless you set the option, and on API spans for Sessions API requests other than requests to one thread. |

### Content attributes

Attributes tagged with <Badge>Content</Badge> are only on spans in content mode, from the SDK and the API alike. See [how the content modes differ in the guide](https://platform.claude.com/docs/en/manage-claude/opentelemetry#choose-a-content-mode). When this content is too large, the SDK and the API [shorten it](https://platform.claude.com/docs/en/manage-claude/opentelemetry#content-limits) and set `anthropic.content.truncated` to `true`. If Anthropic's safeguards withhold content from a response, the API's spans don't include that content either.

The message attributes are JSON strings in the message format of the OpenTelemetry GenAI conventions. Each Anthropic content block becomes one GenAI conventions message part, on the Messages API and in Managed Agents message events such as `agent.message`:

| Anthropic content block                                                                         | GenAI conventions message part                                                                                                                               |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `text`                                                                                          | `text`                                                                                                                                                       |
| `tool_use`, `server_tool_use`                                                                   | `tool_call`, with `anthropic_toolset_name` for a `tool_use` block that has a `toolset_name`, such as `computer`                                              |
| `mcp_tool_use`                                                                                  | `tool_call` with `anthropic_mcp_server_name`                                                                                                                 |
| `tool_result`, `mcp_tool_result`, a server tool's result block such as `web_search_tool_result` | `tool_call_response`                                                                                                                                         |
| `thinking`                                                                                      | `reasoning`, without the `thinking` block's signature. Not in Managed Agents spans, because the `agent.thinking` event doesn't include the thinking content. |
| Any other block, such as `image`                                                                | The block's `type` with the prefix `anthropic_`, such as `anthropic_image`. The part has no other fields.                                                    |

Each Managed Agents tool use or tool result event also becomes one GenAI conventions message part:

| Managed Agents event                                                                        | GenAI conventions message part               |
| ------------------------------------------------------------------------------------------- | -------------------------------------------- |
| `agent.tool_use`, `agent.custom_tool_use`                                                   | `tool_call`                                  |
| `agent.mcp_tool_use`                                                                        | `tool_call` with `anthropic_mcp_server_name` |
| `user.tool_result`, `user.custom_tool_result`, `agent.tool_result`, `agent.mcp_tool_result` | `tool_call_response`                         |

### Token usage

The following spans have token usage attributes: [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create), [`anthropic.model_request`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-model-request), [`anthropic.compaction`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-compaction), and [`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-outcome-evaluation). The values are for each span's step, for example the request, the model request, or the compaction. To count each token once, see [how to count tokens in the guide](https://platform.claude.com/docs/en/manage-claude/opentelemetry#count-tokens).

| Attribute                                                  | Type  | Description                                                                                                                                                                                         |
| ---------------------------------------------------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.usage.input_tokens`                                | `int` | The input tokens, cache reads and writes included.                                                                                                                                                  |
| `gen_ai.usage.output_tokens`                               | `int` | The output tokens.                                                                                                                                                                                  |
| `gen_ai.usage.cache_write.input_tokens`                    | `int` | The tokens written to the prompt cache. Absent on [`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-outcome-evaluation) spans. |
| `anthropic.usage.cache_creation.ephemeral_5m_input_tokens` | `int` | The tokens written to the 5-minute cache. Only on the spans for Messages API requests. On a streaming response's SDK span, only the tokens written before the first output token.                   |
| `anthropic.usage.cache_creation.ephemeral_1h_input_tokens` | `int` | The tokens written to the 1-hour cache. Only on the spans for Messages API requests. On a streaming response's SDK span, only the tokens written before the first output token.                     |
| `gen_ai.usage.cache_read.input_tokens`                     | `int` | The tokens read from the prompt cache. Absent on [`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-outcome-evaluation) spans.  |

## Spans

A span can come from the SDK in the application or from the API, so each span in this reference lists its sources. Descriptions that start with **Messages API:** or **Managed Agents:** are for that product's spans. Attribute descriptions that start with a source, such as **SDK:** or **API:**, are for that source's spans.

### `anthropic.messages.create`

* **Source:** The SDK and the API.
* **Kind:** `CLIENT` from the SDK, `SERVER` from the API.
* **Parent of the SDK span:** The span that is current in the application when it calls the method. If no span is current, there's no parent.
* **Parent of the API span:** The span in the request's `traceparent` header, which is the SDK span when the request comes from the SDK. Without the header, the API span has no parent. See [how to send the `traceparent` header](https://platform.claude.com/docs/en/manage-claude/opentelemetry/api#connect-api-spans-to-your-own-traces).
* **Children of the SDK span:** The API span for that request.
* **Children of the API span:** An [`anthropic.model_request`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-model-request) span for each model request, a [tool span](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use) for each use of a server tool or an MCP connector tool that the API runs in the request, and an [`anthropic.compaction`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-compaction) span for each compaction.

The SDK emits this span for each Messages request, streamed or not.

The API emits this span for each [`POST /v1/messages`](https://platform.claude.com/docs/en/api/messages/create) request that it authenticates. It doesn't emit the span for a request to the [OpenAI-compatible endpoint](https://platform.claude.com/docs/en/cli-sdks-libraries/libraries/openai-sdk), `POST /v1/chat/completions`.

The API emits one span for a request, even when a [fallback model](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback) serves it.

The span has the [token usage attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#token-usage). The SDK span also has the attributes of every [SDK span for a request](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-resources-method).

| Attribute                                  | Type       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`                    | `string`   | `chat`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `gen_ai.request.model`                     | `string`   | The request's [`model`](https://platform.claude.com/docs/en/api/messages/create#create.model).                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `gen_ai.response.id`                       | `string`   | The response's [`id`](https://platform.claude.com/docs/en/api/messages/create#message).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `gen_ai.response.model`                    | `string`   | The model that served the request. It differs from the requested model when the request uses a model alias, or when a [fallback model](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback) served the request.                                                                                                                                                                                                                                                                                                                                 |
| `anthropic.message.stop_reason`            | `string`   | The response's [`stop_reason`](https://platform.claude.com/docs/en/api/messages#stop_reason), for example `end_turn`.                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `anthropic.response.service_tier`          | `string`   | The service tier that served the request: the response's [`usage.service_tier`](https://platform.claude.com/docs/en/api/messages#usage). See [how requests get assigned tiers](https://platform.claude.com/docs/en/api/service-tiers#how-requests-get-assigned-tiers).                                                                                                                                                                                                                                                                                                  |
| `error.type`                               | `string`   | A failed request's [error type](https://platform.claude.com/docs/en/api/errors#http-errors), for example `rate_limit_error`.<br />**SDK:** Also the other values in [SDK spans for requests](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-resources-method).<br />**API:** `api_error` when the API ends the request without an error response.                                                                                                                                                                                                |
| `gen_ai.response.time_to_first_chunk`      | `double`   | Only on a streaming response's SDK span. The seconds from when the SDK first sent the request to the stream's first `content_block_delta` event, if it has one.                                                                                                                                                                                                                                                                                                                                                                                                         |
| `gen_ai.usage.reasoning.output_tokens`     | `int`      | The response's thinking tokens. They are part of the output tokens. Absent when the response's usage doesn't have details for the output tokens.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `anthropic.usage.compaction.input_tokens`  | `int`      | Input tokens of the request's [compactions](https://platform.claude.com/docs/en/build-with-claude/compaction), including cache reads and writes. Not part of `gen_ai.usage.input_tokens`. Absent when the response has no compaction.                                                                                                                                                                                                                                                                                                                                   |
| `anthropic.usage.compaction.output_tokens` | `int`      | Output tokens of the request's compactions. Not part of `gen_ai.usage.output_tokens`. Absent when the response has no compaction.                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `gen_ai.request.max_tokens`                | `int`      | The request's [`max_tokens`](https://platform.claude.com/docs/en/api/messages/create#create.max_tokens).                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `gen_ai.request.temperature`               | `double`   | The request's [`temperature`](https://platform.claude.com/docs/en/api/messages/create#create.temperature). Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.request.top_p`                     | `double`   | The request's [`top_p`](https://platform.claude.com/docs/en/api/messages/create#create.top_p). Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `gen_ai.request.top_k`                     | `int`      | The request's [`top_k`](https://platform.claude.com/docs/en/api/messages/create#create.top_k). Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `gen_ai.request.stream`                    | `boolean`  | `true` when the request sets [`stream: true`](https://platform.claude.com/docs/en/api/messages/create#create.stream). Absent otherwise.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `gen_ai.request.reasoning.level`           | `string`   | The [`effort`](https://platform.claude.com/docs/en/api/messages/create#create.output_config.effort) in the request's [`output_config`](https://platform.claude.com/docs/en/api/messages/create#create.output_config). Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                           |
| `gen_ai.output.type`                       | `string`   | `json` when the request sets the output format to JSON. Absent otherwise.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `anthropic.request.service_tier`           | `string`   | The request's [`service_tier`](https://platform.claude.com/docs/en/api/messages/create#create.service_tier). Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `anthropic.thinking.type`                  | `string`   | The request's [`thinking.type`](https://platform.claude.com/docs/en/api/messages/create#create.thinking). Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `anthropic.thinking.budget_tokens`         | `int`      | The [`budget_tokens`](https://platform.claude.com/docs/en/api/messages#thinking_config_enabled.budget_tokens) in the request's [`thinking`](https://platform.claude.com/docs/en/api/messages/create#create.thinking) object. Absent when the request doesn't set it.                                                                                                                                                                                                                                                                                                    |
| `anthropic.beta`                           | `string[]` | Only on the SDK span. The beta names in the request's [`anthropic-beta`](https://platform.claude.com/docs/en/api/beta/messages/create#create.betas) header.                                                                                                                                                                                                                                                                                                                                                                                                             |
| `gen_ai.system_instructions`               | `string`   | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`SystemInstructions`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-system-instructions.json) schema. The request's [`system`](https://platform.claude.com/docs/en/api/messages/create#create.system) prompt.                                                                                                                                                                                                     |
| `gen_ai.input.messages`                    | `string`   | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`InputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-input-messages.json) schema. The request's [`messages`](https://platform.claude.com/docs/en/api/messages/create#create.messages).                                                                                                                                                                                                                  |
| `gen_ai.output.messages`                   | `string`   | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`OutputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-output-messages.json) schema. The response's [`content`](https://platform.claude.com/docs/en/api/messages/create#message), as one `assistant` message.<br />**SDK:** On a stream, only when the application reads the stream as [Tracing a stream](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#trace-a-stream) describes. |
| `gen_ai.request.stop_sequences`            | `string[]` | <Badge>Content</Badge> The request's [`stop_sequences`](https://platform.claude.com/docs/en/api/messages/create#create.stop_sequences).                                                                                                                                                                                                                                                                                                                                                                                                                                 |

A request's spans don't have the response's server tool usage counts, such as `web_search_requests`. Instead, the API emits a [tool span](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use) for each use of a server tool.

### `anthropic.messages.count_tokens`

* **Source:** The SDK. The API doesn't emit a span for [`POST /v1/messages/count_tokens`](https://platform.claude.com/docs/en/api/messages/count_tokens).
* **Kind:** `CLIENT`.
* **Parent:** The span that is current in the application when it calls the method, or none if no span is current.
* **Children:** None.

| Attribute                                     | Type     | Description                                                                                         |
| --------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------- |
| `gen_ai.request.model`                        | `string` | The request's model.                                                                                |
| `anthropic.message.count_tokens.input_tokens` | `int`    | The token count in the response. This count isn't usage. Don't include it when you sum token usage. |

### `anthropic.sessions.create`

The same as [`anthropic.sessions.<method>`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-method), except for the following children and attributes:

* **Children of the SDK span:** The API span for that request.
* **Children of the API span:** The first turn's [`anthropic.session.turn`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-turn) span, when the request has non-empty [`initial_events`](https://platform.claude.com/docs/en/api/beta/sessions/create#create.initial_events).

| Attribute                          | Type     | Description                                                                                           |
| ---------------------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `gen_ai.agent.id`                  | `string` | The ID of the agent that the session was created from.                                                |
| `gen_ai.agent.name`                | `string` | That agent's name.<br />**SDK:** Absent when the request failed.                                      |
| `gen_ai.request.model`             | `string` | The model of that agent, which runs the primary thread.<br />**SDK:** Absent when the request failed. |
| `anthropic.session.environment.id` | `string` | The ID of the session's environment.                                                                  |

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

The same as [`anthropic.sessions.<method>`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-method), except for the API span's children.

* **Children of the SDK span:** The API span for that request.
* **Children of the API span:** The [`anthropic.session.turn`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-turn) span for each turn that starts because of the request's events.

### `anthropic.sessions.update`

The same as [`anthropic.sessions.<method>`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-method), except for the API span's children.

* **Children of the SDK span:** The API span for that request.
* **Children of the API span:** The [`anthropic.session.turn`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-turn) span for each turn that resumes because the request raises or removes the [session budget](https://platform.claude.com/docs/en/managed-agents/budgets#resume-a-session-at-its-budget).

### `anthropic.session.turn`

* **Source:** The API, for Managed Agents sessions.

* **Kind:** `INTERNAL`.

* **Parent:** It depends on why the turn started:

  * The [`anthropic.sessions.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-create) span, for the first turn of a session that was created with non-empty [`initial_events`](https://platform.claude.com/docs/en/api/beta/sessions/create#create.initial_events).
  * The [`anthropic.sessions.events.send`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-events-send) span for the request in which the event was sent, for a turn that started because of an event, for example a [`user.message`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_user_message_event) event.
  * The [`anthropic.sessions.update`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-sessions-update) span, for a turn that resumes because the session budget was raised or removed through the request.
  * The `anthropic.session.turn` span for the turn of [the agent that the session runs](https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration) during which that agent started this turn, for a turn on another thread.
  * None, for a turn that starts because an agent on another thread replied or finished its turn, such as an agent that the primary agent called.

* **Children:**

  * An [`anthropic.model_request`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-model-request) span for each model request in the turn.
  * A tool span each time the API runs a tool in the turn, except in the [cases listed in the tool span section](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use).
  * An `anthropic.session.turn` span for each turn that the agent that the session runs started on another thread during this turn.
  * An [`anthropic.session.outcome_evaluation`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-outcome-evaluation) span for each iteration of an outcome evaluation that this turn starts.

A turn starts when its thread enters the `running` state and ends when the thread leaves it.

| Attribute                            | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`              | `string` | `invoke_agent`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `gen_ai.agent.id`                    | `string` | The ID of the agent that runs the turn's thread. Absent on an [advisor](https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration#advisor-threads) thread.                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.agent.name`                  | `string` | That agent's name. `anthropic.advisor` on an advisor thread.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.request.model`               | `string` | That agent's model. On an advisor thread, the advisor's model.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `anthropic.session.turn.stop_reason` | `string` | Why the turn ended: the [`session.thread_status_idle`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_session_thread_status_idle_event) event's [`stop_reason.type`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_session_thread_status_idle_event), for example `requires_action`. Absent when the thread didn't go idle.                                                                                                                  |
| `error.type`                         | `string` | The [`error.type`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_session_error_event) of the [`session.error`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_session_error_event) event that ended the turn, if the turn failed.                                                                                                                                                                                                            |
| `gen_ai.agent.description`           | `string` | That agent's description. Absent on an advisor thread or when the agent doesn't have one.                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `gen_ai.system_instructions`         | `string` | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`SystemInstructions`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-system-instructions.json) schema. The system prompt in effect for the turn. Only on a thread's first turn. Absent on an advisor thread.                                                                                                                                                 |
| `gen_ai.input.messages`              | `string` | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`InputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-input-messages.json) schema. The turn's input events: user messages and tool results, [`system.message`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_system_message_event_params) events, and messages from other threads. Absent on an advisor thread. |
| `gen_ai.output.messages`             | `string` | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`OutputMessages`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-output-messages.json) schema. The turn's output events: the agent's messages, tool uses, and tool results.                                                                                                                                                                                  |

### `anthropic.model_request`

* **Source:** The API, for Messages API requests and Managed Agents sessions.

* **Kind:** `INTERNAL`.

* **Parent:**

  * **Messages API:** The [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) span for the request.
  * **Managed Agents:** The [`anthropic.session.turn`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-turn) span for the turn that makes the request.

* **Children:** None.

On the Messages API, each span is one model request within the API request.

The span has the [token usage attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#token-usage).

| Attribute               | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gen_ai.operation.name` | `string` | Only on the spans for Managed Agents sessions, where it's `chat`. On the Messages API, the [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) span for the request is the `chat` operation.                                                                                                                                                                                    |
| `gen_ai.request.model`  | `string` | The request's model.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `gen_ai.response.model` | `string` | Only on the spans for Messages API requests. The model that ran the model request.                                                                                                                                                                                                                                                                                                                                                               |
| `error.type`            | `string` | **Messages API:** The [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) span's `error.type`, if the request failed during this model request.<br />**Managed Agents:** If the model request failed, its [error type](https://platform.claude.com/docs/en/api/errors#http-errors), for example `rate_limit_error`. `api_error` if the model request failed without a response. |

### `anthropic.tool_use`, `anthropic.mcp_tool_use`, and `anthropic.custom_tool_use`

* **Source:** The SDK and the API.

* **Name:** `anthropic.tool_use <tool>`, `anthropic.mcp_tool_use <tool>`, or `anthropic.custom_tool_use <tool>`, where `<tool>` is the tool's name.

* **Kind:** `INTERNAL`.

* **Parent of the SDK span:** The span that is current in the application when the tool starts, which in the Messages tool runner is the [`anthropic.messages.tool_runner`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-tool-runner) span. If no span is current, there's no parent.

* **Parent of the API span:**

  * **Messages API:** The [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) span for the request in which the API runs the tool.
  * **Managed Agents:** The [`anthropic.session.turn`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-turn) span for the turn in which the tool runs. For a tool use that waits for a [`user.tool_confirmation`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_user_tool_confirmation_event) event, that is the turn that starts because of the confirmation.
  * For a tool use from code that another tool runs, the tool span for that tool. On the Messages API, that tool is the [code execution tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool).

* **Children of the SDK span:** The spans that the tool's code starts.

* **Children of the API span:** A tool span for each tool use from the code that this tool runs. For example, code that the code execution tool runs might use `web_search`.

The span name prefix depends on the type of tool:

* `anthropic.tool_use <tool>` is the span for each use of a [server tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools) on the Messages API or of a tool from the agent toolset of Managed Agents. The API runs the agent toolset tools, except in a [self-hosted sandbox](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#trace-a-self-hosted-sandbox), where the environment worker runs them.
* `anthropic.mcp_tool_use <tool>` is the span for each use of an MCP tool, in the SDK, on the Messages API, and on Managed Agents. In the SDK, it's a tool from an MCP helper that the [Messages tool runner](https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-runner) or the [session tool runner](https://platform.claude.com/docs/en/managed-agents/self-hosted-sandboxes-reference#session-tool-runner) runs. On the Messages API, the tool comes from the [MCP connector](https://platform.claude.com/docs/en/agents-and-tools/mcp-connector). On Managed Agents, if the [connection to the MCP server fails](https://platform.claude.com/docs/en/managed-agents/mcp-connector#handle-connection-and-authentication-failures), the span name doesn't include the tool name.
* `anthropic.custom_tool_use <tool>` is the span for each use of a tool that the application defines and a tool runner runs. Only the SDK emits this span.

The API doesn't emit a tool span in the following cases:

* The model asks to use a tool that the application runs, such as a [custom tool](https://platform.claude.com/docs/en/managed-agents/tools). If a tool runner in the SDK runs the tool, the tool runner emits its span.
* **Managed Agents:** The agent uses a tool that runs in a self-hosted sandbox. The worker in the SDK, which runs the tool, emits its span. See [how to trace a self-hosted sandbox](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#trace-a-self-hosted-sandbox).
* **Managed Agents:** The agent uses a [multiagent](https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration) tool or the [advisor tool](https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration#give-the-session-an-advisor).
* **Managed Agents:** The agent asks to use a tool, but the server denies the use under the [`auto` permission policy](https://platform.claude.com/docs/en/managed-agents/permission-policies#let-the-server-evaluate-each-call-with-auto), or the application denies it in a [`user.tool_confirmation`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_user_tool_confirmation_event) event.

| Attribute                             | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`               | `string` | `execute_tool`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `gen_ai.tool.name`                    | `string` | The tool's name, for example `bash`. On API spans, an MCP tool's name doesn't have the server name. On Managed Agents, if the connection to the MCP server failed, it's the name that the model generated and is only on spans in content mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `gen_ai.tool.call.id`                 | `string` | **Messages API:** The `id` of the block in which the model asked to use the tool: a [`tool_use`](https://platform.claude.com/docs/en/api/messages#tool_use_block), [`server_tool_use`](https://platform.claude.com/docs/en/api/messages#server_tool_use_block), or [`mcp_tool_use`](https://platform.claude.com/docs/en/api/beta/messages#beta_mcp_tool_use_block) block.<br />**Managed Agents:** The ID of the event in which the agent asked to use the tool: an [`agent.tool_use`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_agent_tool_use_event), [`agent.mcp_tool_use`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_agent_mcp_tool_use_event), or [`agent.custom_tool_use`](https://platform.claude.com/docs/en/api/beta/sessions/events#beta_managed_agents_agent_custom_tool_use_event) event. |
| `anthropic.mcp.server.name`           | `string` | Only on the API spans for MCP tools. The name of the tool's MCP server. On the Messages API, the [`mcp_tool_use`](https://platform.claude.com/docs/en/api/beta/messages#beta_mcp_tool_use_block) block's [`server_name`](https://platform.claude.com/docs/en/api/beta/messages#beta_mcp_tool_use_block.server_name).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `gen_ai.conversation.id`              | `string` | The session thread ID, as [Session attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#session-attributes) describes. In the Messages tool runner, the conversation ID passed with the [`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`) option](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#configure-the-sdk), and absent without one. Absent on the API spans for a Messages API request.                                                                                                                                                                                                                                                                                                                                                       |
| `anthropic.session.id`                | `string` | The session ID. Absent for a tool use outside a Managed Agents session, such as on the Messages API or in the Messages tool runner.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `anthropic.session.thread.id`         | `string` | Only on the session tool runner's SDK spans. The session thread ID. Absent for a tool use on the primary thread.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `anthropic.tool.evaluated_permission` | `string` | Only on the spans that the API emits in Managed Agents sessions. The result of evaluating the [permission policy](https://platform.claude.com/docs/en/managed-agents/permission-policies) for the tool use: `allow` or `ask`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `error.type`                          | `string` | The error type, if the tool use failed: `tool_error` when the tool's code raises an error or when the tool returns an error result.<br />**API:** On the Messages API, a server tool's error result instead has its [`error_code`](https://platform.claude.com/docs/en/api/messages#web_search_tool_result_error.error_code), for example `max_uses_exceeded`. On Managed Agents, if the connection to the MCP server failed, `mcp_authentication_failed_error` when authentication failed, otherwise `mcp_connection_failed_error`. If the request failed during the tool use, the request's [error type](https://platform.claude.com/docs/en/api/errors#http-errors).                                                                                                                                                                                                             |
| `gen_ai.tool.description`             | `string` | Only on SDK spans. The description in the tool definition. Absent when the description is empty.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `gen_ai.tool.type`                    | `string` | Only on SDK spans. `function`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `gen_ai.tool.call.arguments`          | `string` | <Badge>Content</Badge> A JSON string that follows the OpenTelemetry [`ToolCallArguments`](https://github.com/open-telemetry/semantic-conventions-genai/blob/e57c543b4889619eb2a05702471937db5119165d/model/gen-ai/gen-ai-tool-call-arguments.json) schema. The tool use's [`input`](https://platform.claude.com/docs/en/api/messages#tool_use_block).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `anthropic.tool_result.content`       | `string` | <Badge>Content</Badge> A JSON string with an array of content blocks or with one object. The `content` of the tool result that goes back to the model. Also for an error result, except on Managed Agents when the connection to the MCP server failed.<br />**API:** On the Messages API, a string `content` becomes an array with one [`text`](https://platform.claude.com/docs/en/api/messages#text_block) block.                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

### `anthropic.compaction`

* **Source:** The API, for Messages API requests.
* **Kind:** `INTERNAL`.
* **Parent:** The [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) span for the request.
* **Children:** None.

The span has the compaction's [token usage attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#token-usage). On [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create), a compaction's usage is in the `anthropic.usage.compaction.*` attributes instead of the `gen_ai.usage.*` totals.

| Attribute    | Type     | Description                                                                                                                          |
| ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `error.type` | `string` | The request's [error type](https://platform.claude.com/docs/en/api/errors#http-errors), if the request failed during the compaction. |

### `anthropic.session.outcome_evaluation`

* **Source:** The API, for Managed Agents sessions.
* **Kind:** `INTERNAL`.
* **Parent:** The [`anthropic.session.turn`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-session-turn) span for the turn that started the iteration, even if that turn ends before the iteration.
* **Children:** None.

The status is unset when the result is `interrupted` and `OK` for any other result.

The span has two of the [token usage attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#token-usage): `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`.

| Attribute                                          | Type     | Description                                                                                                  |
| -------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| `anthropic.session.outcome.id`                     | `string` | The ID of the outcome that the iteration evaluates.                                                          |
| `anthropic.session.outcome_evaluation.result`      | `string` | The iteration's result: `satisfied`, `needs_revision`, `max_iterations_reached`, `failed`, or `interrupted`. |
| `anthropic.session.outcome_evaluation.iteration`   | `int`    | The iteration number.                                                                                        |
| `anthropic.session.outcome_evaluation.explanation` | `string` | <Badge>Content</Badge> The grader's explanation of the result, as plain text.                                |

### `anthropic.messages.tool_runner`

* **Source:** The SDK.
* **Kind:** `INTERNAL`.
* **Parent:** The span that is current in the application when the loop starts, or none if no span is current.
* **Children:** The [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) span for each request in the loop and the [tool span](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use) for each tool use that the runner runs.

The span ends with the loop. If the application stops the runner, the status is unset. If a tool's code raises an error, its tool span has the status `ERROR` and the loop continues. The span doesn't have usage attributes, so read the usage from its [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create) children.

| Attribute                | Type     | Description                                                                                                                                                                                                                                                                                    |
| ------------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.operation.name`  | `string` | `invoke_agent`                                                                                                                                                                                                                                                                                 |
| `gen_ai.request.model`   | `string` | The model of the loop's first request.                                                                                                                                                                                                                                                         |
| `gen_ai.conversation.id` | `string` | The conversation ID passed with the [`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`) option](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#configure-the-sdk). Absent without one. |
| `error.type`             | `string` | The [error type](https://platform.claude.com/docs/en/api/errors#http-errors) of the request that ended the loop, if the loop failed. `client_error` when the runner itself failed.                                                                                                             |
| `gen_ai.output.type`     | `string` | `json` when the requests set the output format to JSON. Absent otherwise.                                                                                                                                                                                                                      |

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

* **Source:** The SDK, for every Message Batches method.
* **Kind:** `CLIENT`.
* **Parent:** The span that is current in the application when it calls the method, or none if no span is current.
* **Children:** None.

The spans also have the attributes of every [SDK span for a request](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-resources-method).

| Attribute                               | Type     | Description                                                                                                                                       |
| --------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `anthropic.message.batch.id`            | `string` | The ID of the batch that the method acts on, or of the new batch for `create`. Absent on `list` and on a failed `create`.                         |
| `anthropic.message.batch.request_count` | `int`    | Only on `create`. The number of items in the [`requests`](https://platform.claude.com/docs/en/api/messages/batches/create#create.requests) array. |

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

* **Source:** The SDK and the API.
* **Kind:** `CLIENT` from the SDK, `SERVER` from the API.
* **Parent of the SDK span:** The span that is current in the application when it calls the method, or none if no span is current.
* **Parent of the API span:** The span in the request's [`traceparent` header](https://platform.claude.com/docs/en/manage-claude/opentelemetry/api#connect-api-spans-to-your-own-traces), which is the SDK span when the request comes from the SDK, or none without the header.
* **Children of the SDK span:** The API span for that request.
* **Children of the API span:** None.

The API emits an `anthropic.sessions.<method>` span for each authenticated request to an endpoint of the [Sessions API](https://platform.claude.com/docs/en/managed-agents/sessions). Requests that the platform sends on a user's behalf, such as a message sent in the Claude Console or a session that a [scheduled deployment](https://platform.claude.com/docs/en/managed-agents/scheduled-deployments) starts, also have one, each in a new trace.

<Accordion title="Span names and endpoints">
  | Span                                       | Endpoint                                                                                                                                  |
  | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
  | `anthropic.sessions.create`                | [`POST /v1/sessions`](https://platform.claude.com/docs/en/api/beta/sessions/create)                                                       |
  | `anthropic.sessions.list`                  | [`GET /v1/sessions`](https://platform.claude.com/docs/en/api/beta/sessions/list)                                                          |
  | `anthropic.sessions.retrieve`              | [`GET /v1/sessions/{session_id}`](https://platform.claude.com/docs/en/api/beta/sessions/retrieve)                                         |
  | `anthropic.sessions.update`                | [`POST /v1/sessions/{session_id}`](https://platform.claude.com/docs/en/api/beta/sessions/update)                                          |
  | `anthropic.sessions.delete`                | [`DELETE /v1/sessions/{session_id}`](https://platform.claude.com/docs/en/api/beta/sessions/delete)                                        |
  | `anthropic.sessions.archive`               | [`POST /v1/sessions/{session_id}/archive`](https://platform.claude.com/docs/en/api/beta/sessions/archive)                                 |
  | `anthropic.sessions.events.send`           | [`POST /v1/sessions/{session_id}/events`](https://platform.claude.com/docs/en/api/beta/sessions/events/send)                              |
  | `anthropic.sessions.events.list`           | [`GET /v1/sessions/{session_id}/events`](https://platform.claude.com/docs/en/api/beta/sessions/events/list)                               |
  | `anthropic.sessions.events.stream`         | [`GET /v1/sessions/{session_id}/events/stream`](https://platform.claude.com/docs/en/api/beta/sessions/events/stream)                      |
  | `anthropic.sessions.resources.add`         | [`POST /v1/sessions/{session_id}/resources`](https://platform.claude.com/docs/en/api/beta/sessions/resources/add)                         |
  | `anthropic.sessions.resources.list`        | [`GET /v1/sessions/{session_id}/resources`](https://platform.claude.com/docs/en/api/beta/sessions/resources/list)                         |
  | `anthropic.sessions.resources.retrieve`    | [`GET /v1/sessions/{session_id}/resources/{resource_id}`](https://platform.claude.com/docs/en/api/beta/sessions/resources/retrieve)       |
  | `anthropic.sessions.resources.update`      | [`POST /v1/sessions/{session_id}/resources/{resource_id}`](https://platform.claude.com/docs/en/api/beta/sessions/resources/update)        |
  | `anthropic.sessions.resources.delete`      | [`DELETE /v1/sessions/{session_id}/resources/{resource_id}`](https://platform.claude.com/docs/en/api/beta/sessions/resources/delete)      |
  | `anthropic.sessions.threads.list`          | [`GET /v1/sessions/{session_id}/threads`](https://platform.claude.com/docs/en/api/beta/sessions/threads/list)                             |
  | `anthropic.sessions.threads.retrieve`      | [`GET /v1/sessions/{session_id}/threads/{thread_id}`](https://platform.claude.com/docs/en/api/beta/sessions/threads/retrieve)             |
  | `anthropic.sessions.threads.archive`       | [`POST /v1/sessions/{session_id}/threads/{thread_id}/archive`](https://platform.claude.com/docs/en/api/beta/sessions/threads/archive)     |
  | `anthropic.sessions.threads.events.list`   | [`GET /v1/sessions/{session_id}/threads/{thread_id}/events`](https://platform.claude.com/docs/en/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/en/api/beta/sessions/threads/events/stream) |
</Accordion>

The span has the [session attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#session-attributes). The SDK span also has the attributes of every [SDK span for a request](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-resources-method).

| Attribute    | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `error.type` | `string` | A failed request's [error type](https://platform.claude.com/docs/en/api/errors#http-errors), for example `rate_limit_error`.<br />**SDK:** Also the other values in [SDK spans for requests](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-resources-method).<br />**API:** `api_error` when the API closed the connection without an error response, or when a stream ended because of a failure in the API. |

### `anthropic.environment.work`

* **Source:** The CLI and the SDK in Python, TypeScript, and Go.
* **Kind:** `INTERNAL`.
* **Parent:** The span that is current in the application when the environment worker or the work poller gets the work item, or none if no span is current. In `ant beta:worker poll`, the span is a root span.
* **Children:** The spans for the requests that the environment worker sends while it handles the work item and the [tool span](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-tool-use-anthropic-mcp-tool-use-and-anthropic-custom-tool-use) for each tool that it runs for the work item.

The environment worker and the work poller are the [SDK helpers](https://platform.claude.com/docs/en/managed-agents/self-hosted-sandboxes#sdk-helpers) that claim work items in a self-hosted sandbox. They emit one `anthropic.environment.work` span for each work item, from when a poll returns the work item until its handling ends.

| Attribute                       | Type     | Description                                                                                                                 |
| ------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| `anthropic.environment.id`      | `string` | The environment ID.                                                                                                         |
| `anthropic.environment.work.id` | `string` | The work item ID.                                                                                                           |
| `anthropic.session.id`          | `string` | The ID of the session that the work item belongs to.                                                                        |
| `error.type`                    | `string` | The `error.type` of the span for the failed request, if a request ended the handling. `client_error` for any other failure. |

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

* **Source:** The SDK.
* **Kind:** `CLIENT`.
* **Parent:** The span that is current in the application when it calls the method, or none if no span is current.
* **Children:** None.

Each SDK method that sends a request and doesn't have a section on this page emits an `anthropic.<resources>.<method>` span, for example `anthropic.models.list` or `anthropic.files.upload`. The request for each later page of a list has its own span.

A span covers its whole request, retries included, and has each attribute of the same-named API span when the SDK has the value. The SDK sets `http.request.method` and `http.route` when it starts the span, so a sampler can use them.

Every SDK span for a request, including [`anthropic.messages.create`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-create), [`anthropic.messages.count_tokens`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-count-tokens), and [`anthropic.messages.batches.<method>`](https://platform.claude.com/docs/en/api/opentelemetry/spans#anthropic-messages-batches-method), has the following attributes:

| Attribute                   | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_ai.conversation.id`    | `string` | The conversation ID passed with the [`conversation_id` (typescript, java, php: `conversationId`; csharp: `ConversationId`; go: `option.WithOpenTelemetryConversationID()`) option](https://platform.claude.com/docs/en/manage-claude/opentelemetry/sdk#configure-the-sdk). Without one, the session thread ID on the Managed Agents requests that [Session attributes](https://platform.claude.com/docs/en/api/opentelemetry/spans#session-attributes) lists, and absent on other requests. |
| `anthropic.<resource>.id`   | `string` | One attribute for each ID in the request's path and one for the ID of an object that the method creates. The name comes from the path, in the singular, for example `anthropic.session.id` or `anthropic.session.thread.id`.                                                                                                                                                                                                                                                                |
| `gen_ai.agent.id`           | `string` | The agent ID, on the agent methods.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `gen_ai.memory.store.id`    | `string` | The memory store ID, on the memory store methods.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `gen_ai.memory.record.id`   | `string` | The memory ID, on the memory methods.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `http.request.resend_count` | `int`    | The number of times that the SDK resent the request, for any reason, such as a retry. Absent when the SDK didn't resend it.                                                                                                                                                                                                                                                                                                                                                                 |
| `error.type`                | `string` | A failed call's [error type](https://platform.claude.com/docs/en/api/errors#http-errors), for example `rate_limit_error`. The HTTP status code, for example `502`, when the error response doesn't have an error type. `connection_error`, `client_timeout_error`, or `client_error` when the call failed in the SDK. `api_error` when the server ended a stream early.                                                                                                                     |
| `server.address`            | `string` | The host of the client's base URL, `api.anthropic.com` by default. On a cloud platform's client, that platform's host.                                                                                                                                                                                                                                                                                                                                                                      |
| `url.query`                 | `string` | The URL's query string, with only the query parameters that the endpoint defines. Absent when there are none. In metadata-only mode, absent when the query has a sensitive parameter, such as `email`.                                                                                                                                                                                                                                                                                      |
| `url.full`                  | `string` | The URL, made of `url.scheme`, `server.address`, the port when the base URL has one, `url.path`, and `url.query`. In metadata-only mode, absent whenever that mode leaves out `url.query`.                                                                                                                                                                                                                                                                                                  |
