---
title: ai.raw.anthropic.claude_code.spans dataset
description: 'The predefined ai.raw.anthropic.claude_code.spans dataset that stores raw Claude Code spans: each prompt traced through its model requests and tool calls.'
url: https://coralogix.com/docs/user-guides/data-layer/default-dataspace/ai-raw-anthropic-claude-code-spans/
product: dataengine
feature: Dataset Management
feature_id: dataspace-dataset-mgmt
feature_identifier: dataengine/dataspace-dataset-mgmt
last_updated: '2026-11-17'
---

# `ai.raw.anthropic.claude_code.spans`

Note

This dataset is restricted by default: no one can read its data until access is granted through a target group rule on its access policy. To grant access, see [Access control](https://coralogix.com/docs/user-guides/data-layer/dataset-management/access-control.md).

## Purpose

The `ai.raw.anthropic.claude_code.spans` dataset stores the spans that [Claude Code](https://coralogix.com/docs/integrations/ai-observability/claude/claude-code.md) sends when tracing is on. Each trace follows one prompt through the model requests and tool calls it triggers, so you can see where a turn spent its time: waiting on the model, waiting on a permission decision, or running a tool.

`ai.raw.anthropic.claude_code.spans` is a [predefined dataset](https://coralogix.com/docs/user-guides/data-layer/default-dataspace/predefined-datasets.md): Coralogix provisions it in the `default` dataspace, and your Claude Code telemetry fills it. Its entity type is `rawAnthropicClaudeCodeSpans`. Claude Code log events go to a separate dataset, [`ai.raw.anthropic.claude_code.logs`](https://coralogix.com/docs/user-guides/data-layer/default-dataspace/ai-raw-anthropic-claude-code-logs.md).

Claude Code spans used to land in your `spans` dataset. They now go here, so they no longer appear next to your application traces.

## How spans reach the dataset

Claude Code sends spans only when tracing is on, which requires `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1` in its `env` block. Coralogix routes a span to this dataset when its OpenTelemetry resource attributes identify Claude Code as the source:

| Resource attribute           | Value               |
| ---------------------------- | ------------------- |
| `cx.integration.source.type` | `claude_code_agent` |

Spans that carry the newer name, `cx.source.integration.type`, also route here. Claude Code metrics use only `cx.integration.source.type`, so keep that name. Spans without either attribute go to your `spans` dataset as before.

## What one span is

Each span is one step of a Claude Code turn. Every turn starts a `claude_code.interaction` root span, and the model requests and tool calls it triggers are its children:

```
claude_code.interaction

├── claude_code.llm_request

├── claude_code.hook

└── claude_code.tool

    ├── claude_code.tool.blocked_on_user

    └── claude_code.tool.execution
```

When the agent starts a subagent, the subagent's model request and tool spans nest under the parent's `claude_code.tool` span.

| Span                               | What it covers                                                                         | Notable attributes                                                                                                                         |
| ---------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `claude_code.interaction`          | One prompt and everything it triggers.                                                 | `user_prompt` (redacted unless `OTEL_LOG_USER_PROMPTS=1`), `user_prompt_length`, `interaction.duration_ms`                                 |
| `claude_code.llm_request`          | One model request, including retries.                                                  | `model`, `input_tokens`, `output_tokens`, `cache_read_tokens`, `cache_creation_tokens`, `ttft_ms`, `duration_ms`, `success`, `stop_reason` |
| `claude_code.tool`                 | One tool call, from the permission check to the result.                                | `tool_name`, `tool_use_id`, `duration_ms`, `result_tokens`                                                                                 |
| `claude_code.tool.blocked_on_user` | Time spent waiting for a permission decision.                                          | `decision`, `source`, `duration_ms`                                                                                                        |
| `claude_code.tool.execution`       | Time spent running the tool.                                                           | `success`, `error`, `duration_ms`                                                                                                          |
| `claude_code.hook`                 | Hooks that ran for one hook event. Sent only with Claude Code's detailed beta tracing. | `hook_event`, `hook_name`, `num_hooks`, `duration_ms`                                                                                      |

Every span also carries a `span.type` attribute that matches its name, plus the same session and user attributes as the [log events](https://coralogix.com/docs/user-guides/data-layer/default-dataspace/ai-raw-anthropic-claude-code-logs.md#common-attributes), such as `session.id` and `user.email`. Use `session.id` to join spans with log events. The `tool_use_id` on a `claude_code.tool` span matches the one on the `claude_code.tool_result` and `claude_code.tool_decision` log events for the same call.

For every span attribute, see the [Claude Code monitoring reference](https://code.claude.com/docs/en/monitoring-usage).

### Content capture

Spans redact prompt text, tool input details, and tool content by default. The same environment variables that add content to log events add it to spans: `OTEL_LOG_USER_PROMPTS=1`, `OTEL_LOG_TOOL_DETAILS=1`, and `OTEL_LOG_TOOL_CONTENT=1`.

## Query the dataset

```
source ai.raw.anthropic.claude_code.spans

| filter $l.operationName == 'claude_code.llm_request'
```

## Next steps

* Set up the source: [Claude Code](https://coralogix.com/docs/integrations/ai-observability/claude/claude-code.md).
* Grant read access to more users: [Access control](https://coralogix.com/docs/user-guides/data-layer/dataset-management/access-control.md).
* See the other datasets Coralogix provisions in [Predefined datasets](https://coralogix.com/docs/user-guides/data-layer/default-dataspace/predefined-datasets.md).
