Extract and upload Claude Code traces
Project description
claude_traces_client
Extract and upload Claude Code traces to a configurable endpoint.
Installation
pip install claude-traces-client
Or install from source:
cd claude_traces_client
pip install -e .
Usage
from claude_traces_client import traced
from claude_code_sdk import query, ClaudeCodeOptions
# Endpoint read from CLAUDE_TRACES_ENDPOINT env var (default: https://claudetraces.dev/api/trace)
async for msg in traced(query(prompt="Hello", options=opts)):
print(msg) # Messages flow through unchanged
# Trace is POSTed automatically after iteration completes
Configuration
| Environment Variable | Default | Description |
|---|---|---|
CLAUDE_TRACES_ENDPOINT |
https://claudetraces.dev/api/trace |
URL to POST traces to |
API
traced(messages, *, project_path=None, headers=None, timeout=30.0, raise_on_upload_error=False)
Wrap a Claude SDK message iterator to upload traces after completion.
Parameters:
messages: AsyncIterator fromquery()orClaudeSDKClientproject_path: Project path for trace lookup (default: cwd)headers: Optional headers for the POST request (e.g.,{"Authorization": "Bearer ..."})timeout: Upload timeout in secondsraise_on_upload_error: If True, raise on upload failure; if False, silently continue
Yields: Messages unchanged from the underlying iterator
How It Works
- Wraps the Claude SDK's async message iterator
- Captures the
session_idfrom the firstSystemMessagewithsubtype='init' - After iteration completes, reads the trace file from
~/.claude/projects/<encoded-path>/<session_id>.jsonl - POSTs the trace contents to the configured endpoint with
Content-Type: application/x-ndjson
Trace File Location
Claude Code writes traces to:
~/.claude/projects/<encoded-path>/<session_id>.jsonl
Where <encoded-path> is the project path with / replaced by - (e.g., /Users/foo/bar becomes -Users-foo-bar).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_traces_client-0.1.2.tar.gz.
File metadata
- Download URL: claude_traces_client-0.1.2.tar.gz
- Upload date:
- Size: 50.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0cc2c5622876ac91e430d77f440a364e8d3aea45117a65f1b21195952e56f06
|
|
| MD5 |
0b93f3d5abbc5fb4f5b0d17ce483e278
|
|
| BLAKE2b-256 |
061b6e8a075e85c28739289cd976ee9d3fea5305af20df69aba1edc2422a0a49
|
File details
Details for the file claude_traces_client-0.1.2-py3-none-any.whl.
File metadata
- Download URL: claude_traces_client-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecc5dd5665cbe18a4c6ee6c0caa6ab7e6803f6ab31f15b17fbe824a594d2e1d1
|
|
| MD5 |
92c4e59ec2a2489bfc92af9cdc5a23c6
|
|
| BLAKE2b-256 |
b9d39d109647d87fd43db4bef5c79dbae93bd6c38a5c42a3d6033073ddaeea50
|