Files
fathom/internal/ingest/testdata/claude_code_logs_content.json
zzg c37dff07b0 Add OTLP ingest and span/log correlation
Decoders for OTLP/HTTP JSON traces and logs, tested against payloads
captured from a real `claude -p` run rather than hand-written fixtures.

Correlation is not a span_id join. Claude Code stamps every content log
record with the ROOT span's id, so joining on span_id piles the entire
transcript onto the root and leaves every interesting span empty -- it
fails while looking like it worked. Instead this joins on typed identity
keys both sides carry: tool_use_id for tool results, request_id for
model responses, falling back to innermost-containing-span by timestamp
for records with no key at all.

Identity attributes (user.email, user.id, account and org ids) are
dropped at ingest by default, before anything reaches disk, with an
opt-in to retain them.

Also handles base64 trace ids from SDKs that ignore the OTLP/JSON hex
mapping, nanosecond timestamps beyond float64's exact integer range,
and span cycles from trace id collisions.
2026-09-15 21:34:34 -07:00

1173 lines
25 KiB
JSON

{
"resourceLogs": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "claude-code"
}
},
{
"key": "host.arch",
"value": {
"stringValue": "arm64"
}
},
{
"key": "os.type",
"value": {
"stringValue": "darwin"
}
},
{
"key": "os.version",
"value": {
"stringValue": "25.6.0"
}
},
{
"key": "service.version",
"value": {
"stringValue": "2.1.266"
}
}
],
"droppedAttributesCount": 0
},
"scopeLogs": [
{
"scope": {
"name": "com.anthropic.claude_code.events",
"version": "2.1.266"
},
"logRecords": [
{
"timeUnixNano": "1789532371428000000",
"observedTimeUnixNano": "1789532371428000000",
"body": {
"stringValue": "claude_code.user_prompt"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "user_prompt"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:31.428Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 12
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "prompt_length",
"value": {
"stringValue": "100"
}
},
{
"key": "prompt",
"value": {
"stringValue": "Use ls to list the .txt files in this directory, then read a.txt and tell me its contents. Be brief."
}
},
{
"key": "message.uuid",
"value": {
"stringValue": "145b8530-b6c3-440f-bc14-6b85f4926071"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
}
]
}
]
},
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "claude-code"
}
},
{
"key": "host.arch",
"value": {
"stringValue": "arm64"
}
},
{
"key": "os.type",
"value": {
"stringValue": "darwin"
}
},
{
"key": "os.version",
"value": {
"stringValue": "25.6.0"
}
},
{
"key": "service.version",
"value": {
"stringValue": "2.1.266"
}
}
],
"droppedAttributesCount": 0
},
"scopeLogs": [
{
"scope": {
"name": "com.anthropic.claude_code.events",
"version": "2.1.266"
},
"logRecords": [
{
"timeUnixNano": "1789532374686000000",
"observedTimeUnixNano": "1789532374686000000",
"body": {
"stringValue": "claude_code.tool_decision"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "tool_decision"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:34.686Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 13
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "decision",
"value": {
"stringValue": "accept"
}
},
{
"key": "source",
"value": {
"stringValue": "config"
}
},
{
"key": "tool_name",
"value": {
"stringValue": "Bash"
}
},
{
"key": "tool_use_id",
"value": {
"stringValue": "toolu_01TjbRivF1tGcKhTCazBkVUU"
}
},
{
"key": "tool_source",
"value": {
"stringValue": "builtin"
}
},
{
"key": "tool_parameters",
"value": {
"stringValue": "{\"bash_command\":\"ls\",\"full_command\":\"ls *.txt 2>/dev/null\",\"description\":\"List .txt files in current directory\"}"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "6c76effa0e43d56b"
},
{
"timeUnixNano": "1789532374698000000",
"observedTimeUnixNano": "1789532374698000000",
"body": {
"stringValue": "claude_code.api_request"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "api_request"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:34.698Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 14
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "model",
"value": {
"stringValue": "claude-sonnet-5"
}
},
{
"key": "input_tokens",
"value": {
"intValue": 2
}
},
{
"key": "output_tokens",
"value": {
"intValue": 165
}
},
{
"key": "cache_read_tokens",
"value": {
"intValue": 32682
}
},
{
"key": "cache_creation_tokens",
"value": {
"intValue": 0
}
},
{
"key": "cost_usd",
"value": {
"doubleValue": 0.0081904
}
},
{
"key": "cost_usd_micros",
"value": {
"intValue": 8190
}
},
{
"key": "duration_ms",
"value": {
"intValue": 3250
}
},
{
"key": "request_id",
"value": {
"stringValue": "req_011Cf6UYEtKdoH9nsMYPNQ4S"
}
},
{
"key": "client_request_id",
"value": {
"stringValue": "6ca8e9ad-82fe-49e0-a82f-3b1e7e9b2fce"
}
},
{
"key": "speed",
"value": {
"stringValue": "normal"
}
},
{
"key": "query_source",
"value": {
"stringValue": "sdk"
}
},
{
"key": "effort",
"value": {
"stringValue": "high"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
},
{
"timeUnixNano": "1789532374770000000",
"observedTimeUnixNano": "1789532374770000000",
"body": {
"stringValue": "claude_code.tool_result"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "tool_result"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:34.770Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 15
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "tool_name",
"value": {
"stringValue": "Bash"
}
},
{
"key": "tool_use_id",
"value": {
"stringValue": "toolu_01TjbRivF1tGcKhTCazBkVUU"
}
},
{
"key": "success",
"value": {
"stringValue": "true"
}
},
{
"key": "duration_ms",
"value": {
"stringValue": "82"
}
},
{
"key": "tool_parameters",
"value": {
"stringValue": "{\"bash_command\":\"ls\",\"full_command\":\"ls *.txt 2>/dev/null\",\"description\":\"List .txt files in current directory\"}"
}
},
{
"key": "tool_input",
"value": {
"stringValue": "{\"command\":\"ls *.txt 2>/dev/null\",\"description\":\"List .txt files in current directory\"}"
}
},
{
"key": "tool_input_size_bytes",
"value": {
"stringValue": "87"
}
},
{
"key": "tool_result_size_bytes",
"value": {
"stringValue": "17"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
}
]
}
]
},
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "claude-code"
}
},
{
"key": "host.arch",
"value": {
"stringValue": "arm64"
}
},
{
"key": "os.type",
"value": {
"stringValue": "darwin"
}
},
{
"key": "os.version",
"value": {
"stringValue": "25.6.0"
}
},
{
"key": "service.version",
"value": {
"stringValue": "2.1.266"
}
}
],
"droppedAttributesCount": 0
},
"scopeLogs": [
{
"scope": {
"name": "com.anthropic.claude_code.events",
"version": "2.1.266"
},
"logRecords": [
{
"timeUnixNano": "1789532378484000000",
"observedTimeUnixNano": "1789532378484000000",
"body": {
"stringValue": "claude_code.api_request"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "api_request"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:38.484Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 19
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "model",
"value": {
"stringValue": "claude-sonnet-5"
}
},
{
"key": "input_tokens",
"value": {
"intValue": 2
}
},
{
"key": "output_tokens",
"value": {
"intValue": 36
}
},
{
"key": "cache_read_tokens",
"value": {
"intValue": 34370
}
},
{
"key": "cache_creation_tokens",
"value": {
"intValue": 131
}
},
{
"key": "cost_usd",
"value": {
"doubleValue": 0.007762
}
},
{
"key": "cost_usd_micros",
"value": {
"intValue": 7762
}
},
{
"key": "duration_ms",
"value": {
"intValue": 1569
}
},
{
"key": "request_id",
"value": {
"stringValue": "req_011Cf6UYe4LtJoA6symymNDt"
}
},
{
"key": "client_request_id",
"value": {
"stringValue": "6652c751-15cd-4215-9fc6-197c490f0a56"
}
},
{
"key": "speed",
"value": {
"stringValue": "normal"
}
},
{
"key": "query_source",
"value": {
"stringValue": "sdk"
}
},
{
"key": "effort",
"value": {
"stringValue": "high"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
},
{
"timeUnixNano": "1789532378484000000",
"observedTimeUnixNano": "1789532378484000000",
"body": {
"stringValue": "claude_code.assistant_response"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "assistant_response"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:38.484Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 20
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "response_length",
"value": {
"intValue": 59
}
},
{
"key": "response",
"value": {
"stringValue": ".txt files: a.txt, b.txt, c.txt. Contents of a.txt: `alpha`"
}
},
{
"key": "request_id",
"value": {
"stringValue": "req_011Cf6UYe4LtJoA6symymNDt"
}
},
{
"key": "message.uuid",
"value": {
"stringValue": "f5a6b150-dfd9-4257-91d5-63cdd783d8b1"
}
},
{
"key": "model",
"value": {
"stringValue": "claude-sonnet-5"
}
},
{
"key": "query_source",
"value": {
"stringValue": "sdk"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
},
{
"timeUnixNano": "1789532379421000000",
"observedTimeUnixNano": "1789532379421000000",
"body": {
"stringValue": "claude_code.hook_execution_start"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "hook_execution_start"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:39.421Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 21
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "hook_event",
"value": {
"stringValue": "Stop"
}
},
{
"key": "hook_name",
"value": {
"stringValue": "Stop"
}
},
{
"key": "num_hooks",
"value": {
"stringValue": "1"
}
},
{
"key": "managed_only",
"value": {
"stringValue": "false"
}
},
{
"key": "hook_source",
"value": {
"stringValue": "merged"
}
},
{
"key": "safe_mode",
"value": {
"stringValue": "false"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
},
{
"timeUnixNano": "1789532379464000000",
"observedTimeUnixNano": "1789532379464000000",
"body": {
"stringValue": "claude_code.hook_execution_complete"
},
"attributes": [
{
"key": "user.id",
"value": {
"stringValue": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
"key": "session.id",
"value": {
"stringValue": "6f57a3e3-2553-4f07-bd2d-4919be9f654d"
}
},
{
"key": "organization.id",
"value": {
"stringValue": "11111111-1111-1111-1111-111111111111"
}
},
{
"key": "user.email",
"value": {
"stringValue": "someone@example.com"
}
},
{
"key": "user.account_uuid",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "user.account_id",
"value": {
"stringValue": "00000000-0000-0000-0000-000000000000"
}
},
{
"key": "terminal.type",
"value": {
"stringValue": "tmux"
}
},
{
"key": "event.name",
"value": {
"stringValue": "hook_execution_complete"
}
},
{
"key": "event.timestamp",
"value": {
"stringValue": "2026-09-16T04:19:39.464Z"
}
},
{
"key": "event.sequence",
"value": {
"intValue": 22
}
},
{
"key": "prompt.id",
"value": {
"stringValue": "6af3bd28-f110-4ce9-95f6-b6903e81958a"
}
},
{
"key": "hook_event",
"value": {
"stringValue": "Stop"
}
},
{
"key": "hook_name",
"value": {
"stringValue": "Stop"
}
},
{
"key": "num_hooks",
"value": {
"stringValue": "1"
}
},
{
"key": "num_success",
"value": {
"stringValue": "0"
}
},
{
"key": "num_blocking",
"value": {
"stringValue": "1"
}
},
{
"key": "num_non_blocking_error",
"value": {
"stringValue": "0"
}
},
{
"key": "num_cancelled",
"value": {
"stringValue": "0"
}
},
{
"key": "total_duration_ms",
"value": {
"stringValue": "42"
}
},
{
"key": "managed_only",
"value": {
"stringValue": "false"
}
},
{
"key": "hook_source",
"value": {
"stringValue": "merged"
}
},
{
"key": "safe_mode",
"value": {
"stringValue": "false"
}
}
],
"droppedAttributesCount": 0,
"flags": 1,
"traceId": "19f0b758e2c26a0f65e7050c78d30ebe",
"spanId": "4028c5170879c65b"
}
]
}
]
}
]
}