MLflow tracing for Claude Code sessions with Databricks integration
Project description
Claude Code MLflow Tracing
A simple helper CLI to help you setup the MLFlow tracing in Claude Code in Databricks. While the MLFlow documentation already can set up claude code tracing for you with the command mlflow autolog claude this goes a step further in guiding you through the process such to make sure your experiments have the same naming convention as well as use the correct profile and prevent the use of a PAT.
Installation
uv add claudetracing
Or with pip:
pip install claudetracing
Quick Start
Run the interactive setup in your project directory:
traces init
This will:
- Authenticate with Databricks (or use existing credentials)
- Configure your experiment path (shared or personal)
- Create
.claude/settings.jsonwith the proper hooks - Update
.gitignore
Restart Claude Code after setup. Traces are automatically sent to Databricks when sessions end.
CLI Commands
traces init # Interactive setup
traces list # List available experiments
traces search # Search recent traces
traces search -e <experiment> # Filter by experiment name
traces search --hours 24 # Last 24 hours
traces search --trace-id <id> # Get specific trace
traces search -f json # Output as JSON
traces search -f context # LLM-optimized format
Enrichments
Enrichments add extra metadata to your traces. They are optional and can be enabled per-project. Multiple enrichments can be active simultaneously.
Available Enrichments
| Name | Description |
|---|---|
git |
Adds git repository context: commit ID, branch, remote URL, repo name |
files |
Adds list of files modified (written/edited) during the session |
tokens |
Adds token usage statistics including cache metrics |
Managing Enrichments
traces enrichment list # List available enrichments
traces enrichment info git # Show details about an enrichment
traces enrichment add git files # Enable multiple enrichments
traces enrichment remove tokens # Disable an enrichment
After adding or removing enrichments, restart Claude Code to apply the changes.
Git Enrichment
Correlate traces with specific commits and branches:
git.commit_id- Full commit SHAgit.branch- Current branch namegit.remote_url- Origin remote URLgit.repo_name- Repository name (e.g.,org/repo)
Files Enrichment
Track which files were modified during the session:
files.modified- JSON array of file paths that were written or edited
Tokens Enrichment
Monitor token consumption and cache efficiency:
tokens.input- Total input tokenstokens.output- Total output tokenstokens.cache_read- Tokens read from prompt cachetokens.cache_creation- Tokens written to prompt cachetokens.total- Total tokens (input + output)
MLflow tracing for Claude Code sessions with Databricks integration. Automatically captures conversations, tool usage, and session metadata.
Why Trace Claude Code Sessions?
When Claude Code becomes part of your development workflow, visibility into how it's being used becomes valuable:
- Review past sessions - What did Claude do while you were away? Search and replay any session to understand decisions made.
- Team insights - See how your team uses Claude Code across projects. Identify patterns, common tasks, and areas for improvement.
- Debug failures - When something goes wrong, trace data shows exactly which tools were called, in what order, and what inputs/outputs were involved.
- Cost awareness - Track token usage and session duration to understand resource consumption.
- Compliance & audit - Maintain records of AI-assisted code changes for regulated environments.
Prerequisites
- Python 3.10+
- Databricks CLI installed
- Access to a Databricks workspace
What Gets Traced
- User prompts and Claude responses
- Tool usage (Read, Write, Edit, Bash, etc.)
- Execution timing per operation
- Session metadata (user, working directory, git branch)
How It Works
- The
traces initcommand creates a.claude/settings.jsonfile - This configures a Stop hook that runs when Claude Code sessions end
- The hook calls MLflow's built-in Claude Code tracing to capture the session
- Traces are uploaded to your Databricks MLflow experiment
FAQ
Why might my traces have different metadata than my teammate's?
Enrichment configuration is stored locally per-user in .claude/settings.json. If teammates configure different enrichments, their traces will have different tags. See ADR-001 for the design rationale.
What happens when I join an existing experiment?
During traces init, we check existing traces for enrichment patterns. If enrichments are detected, you'll see:
Enrichment mismatch detected
Existing traces use: files, git, tokens
Options:
[1] Match existing enrichments (recommended)
[2] Continue without enrichments
[3] Cancel setup
Choosing option 1 automatically enables the matching enrichments.
Why warn instead of auto-configuring enrichments?
We chose advisory warnings over enforcement because:
- Teams may intentionally use different enrichments for different use cases
- Some users may not have all enrichments available (e.g., no git repo)
- Respecting user autonomy while surfacing potential issues
License
MIT
Built with Claude Opus 4.5
Project details
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 claudetracing-0.2.0.tar.gz.
File metadata
- Download URL: claudetracing-0.2.0.tar.gz
- Upload date:
- Size: 317.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b22c5594f8de7bea35ce67a02327f362bbbaa40d60f8f81f0488ee9c267b9bf
|
|
| MD5 |
3372549d7acc880f549e69a7bd389c78
|
|
| BLAKE2b-256 |
efde987b363449e48fd772821aaff483327ee3e0a4b1c91cd3b64501ca29287a
|
Provenance
The following attestation bundles were made for claudetracing-0.2.0.tar.gz:
Publisher:
ci.yml on CauchyIO/claudetracing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claudetracing-0.2.0.tar.gz -
Subject digest:
0b22c5594f8de7bea35ce67a02327f362bbbaa40d60f8f81f0488ee9c267b9bf - Sigstore transparency entry: 796302624
- Sigstore integration time:
-
Permalink:
CauchyIO/claudetracing@61336af0a31f05a193091946383a8c4c27f3c2c5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/CauchyIO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@61336af0a31f05a193091946383a8c4c27f3c2c5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file claudetracing-0.2.0-py3-none-any.whl.
File metadata
- Download URL: claudetracing-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceca0975bdb674a1d9cbcee39d7e8a0700adaa23e3c9cf9cb04d7e3d6369a88e
|
|
| MD5 |
e5548a7bec4bb6277e8e70106c1d6570
|
|
| BLAKE2b-256 |
9305130475900b215e4fd6ae896462a8b4c8704d632c56e437a7a3aece715de2
|
Provenance
The following attestation bundles were made for claudetracing-0.2.0-py3-none-any.whl:
Publisher:
ci.yml on CauchyIO/claudetracing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claudetracing-0.2.0-py3-none-any.whl -
Subject digest:
ceca0975bdb674a1d9cbcee39d7e8a0700adaa23e3c9cf9cb04d7e3d6369a88e - Sigstore transparency entry: 796302640
- Sigstore integration time:
-
Permalink:
CauchyIO/claudetracing@61336af0a31f05a193091946383a8c4c27f3c2c5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/CauchyIO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@61336af0a31f05a193091946383a8c4c27f3c2c5 -
Trigger Event:
push
-
Statement type: