traceweave 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- traceweave-0.1.2/.github/workflows/ci.yml +48 -0
- traceweave-0.1.2/.gitignore +81 -0
- traceweave-0.1.2/LICENSE +21 -0
- traceweave-0.1.2/PKG-INFO +323 -0
- traceweave-0.1.2/README.md +269 -0
- traceweave-0.1.2/README_CN.md +269 -0
- traceweave-0.1.2/README_ES.md +269 -0
- traceweave-0.1.2/README_JA.md +269 -0
- traceweave-0.1.2/README_KO.md +269 -0
- traceweave-0.1.2/agent_trace/__init__.py +39 -0
- traceweave-0.1.2/agent_trace/cli.py +81 -0
- traceweave-0.1.2/agent_trace/core/__init__.py +34 -0
- traceweave-0.1.2/agent_trace/core/context.py +66 -0
- traceweave-0.1.2/agent_trace/core/decorators.py +332 -0
- traceweave-0.1.2/agent_trace/core/models.py +177 -0
- traceweave-0.1.2/agent_trace/core/span.py +189 -0
- traceweave-0.1.2/agent_trace/core/tracer.py +273 -0
- traceweave-0.1.2/agent_trace/dashboard/__init__.py +12 -0
- traceweave-0.1.2/agent_trace/dashboard/server.py +252 -0
- traceweave-0.1.2/agent_trace/dashboard/trace_viewer.py +24 -0
- traceweave-0.1.2/agent_trace/dashboard/tui.py +278 -0
- traceweave-0.1.2/agent_trace/examples/__init__.py +1 -0
- traceweave-0.1.2/agent_trace/examples/demo_runner.py +26 -0
- traceweave-0.1.2/agent_trace/exporters/__init__.py +6 -0
- traceweave-0.1.2/agent_trace/exporters/chrome_exporter.py +68 -0
- traceweave-0.1.2/agent_trace/exporters/export.py +28 -0
- traceweave-0.1.2/agent_trace/exporters/json_exporter.py +40 -0
- traceweave-0.1.2/agent_trace/integrations/__init__.py +43 -0
- traceweave-0.1.2/agent_trace/integrations/anthropic_integration.py +157 -0
- traceweave-0.1.2/agent_trace/integrations/langchain_integration.py +181 -0
- traceweave-0.1.2/agent_trace/integrations/openai_integration.py +174 -0
- traceweave-0.1.2/examples/__init__.py +0 -0
- traceweave-0.1.2/examples/multi_agent_demo.py +205 -0
- traceweave-0.1.2/examples/simple_demo.py +31 -0
- traceweave-0.1.2/pyproject.toml +102 -0
- traceweave-0.1.2/tests/__init__.py +0 -0
- traceweave-0.1.2/tests/test_decorators.py +91 -0
- traceweave-0.1.2/tests/test_exporters.py +76 -0
- traceweave-0.1.2/tests/test_models.py +107 -0
- traceweave-0.1.2/tests/test_tracer.py +92 -0
- traceweave-0.1.2/tests/test_tui.py +56 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
pip install -e ".[all]"
|
|
26
|
+
pip install pytest pytest-cov
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: |
|
|
29
|
+
pytest tests/ -v --cov=agent_trace --cov-report=xml
|
|
30
|
+
- name: Upload coverage
|
|
31
|
+
if: matrix.python-version == '3.12'
|
|
32
|
+
uses: codecov/codecov-action@v4
|
|
33
|
+
with:
|
|
34
|
+
file: ./coverage.xml
|
|
35
|
+
|
|
36
|
+
lint:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.12"
|
|
43
|
+
- name: Install dependencies
|
|
44
|
+
run: pip install ruff
|
|
45
|
+
- name: Lint
|
|
46
|
+
run: ruff check agent_trace/
|
|
47
|
+
- name: Format check
|
|
48
|
+
run: ruff format --check agent_trace/
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Environments
|
|
54
|
+
.env
|
|
55
|
+
.venv
|
|
56
|
+
env/
|
|
57
|
+
venv/
|
|
58
|
+
ENV/
|
|
59
|
+
|
|
60
|
+
# IDE
|
|
61
|
+
.vscode/
|
|
62
|
+
.idea/
|
|
63
|
+
*.swp
|
|
64
|
+
*.swo
|
|
65
|
+
*~
|
|
66
|
+
|
|
67
|
+
# mypy
|
|
68
|
+
.mypy_cache/
|
|
69
|
+
dmypy.json
|
|
70
|
+
dmypy.txt
|
|
71
|
+
|
|
72
|
+
# ruff
|
|
73
|
+
.ruff_cache/
|
|
74
|
+
|
|
75
|
+
# OS
|
|
76
|
+
.DS_Store
|
|
77
|
+
Thumbs.db
|
|
78
|
+
|
|
79
|
+
# Project specific
|
|
80
|
+
*.log
|
|
81
|
+
.agent-trace/
|
traceweave-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 traceweave contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: traceweave
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Distributed tracing and observability for AI agents. Datadog for AI Agents.
|
|
5
|
+
Project-URL: Homepage, https://github.com/traceweave/traceweave
|
|
6
|
+
Project-URL: Documentation, https://github.com/traceweave/traceweave#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/traceweave/traceweave
|
|
8
|
+
Project-URL: Issues, https://github.com/traceweave/traceweave/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/traceweave/traceweave/blob/main/CHANGELOG.md
|
|
10
|
+
Author: traceweave contributors
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: agents,ai,distributed-tracing,llm,monitoring,observability,tracing
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
26
|
+
Classifier: Topic :: System :: Monitoring
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Requires-Dist: click>=8.0
|
|
30
|
+
Requires-Dist: orjson>=3.9
|
|
31
|
+
Requires-Dist: pydantic>=2.0
|
|
32
|
+
Requires-Dist: rich>=13.0
|
|
33
|
+
Requires-Dist: textual>=0.40
|
|
34
|
+
Requires-Dist: websockets>=12.0
|
|
35
|
+
Provides-Extra: all
|
|
36
|
+
Requires-Dist: anthropic>=0.18; extra == 'all'
|
|
37
|
+
Requires-Dist: crewai>=0.1.0; extra == 'all'
|
|
38
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'all'
|
|
39
|
+
Requires-Dist: langchain>=0.1.0; extra == 'all'
|
|
40
|
+
Requires-Dist: openai>=1.0; extra == 'all'
|
|
41
|
+
Requires-Dist: pyautogen>=0.2.0; extra == 'all'
|
|
42
|
+
Provides-Extra: anthropic
|
|
43
|
+
Requires-Dist: anthropic>=0.18; extra == 'anthropic'
|
|
44
|
+
Provides-Extra: autogen
|
|
45
|
+
Requires-Dist: pyautogen>=0.2.0; extra == 'autogen'
|
|
46
|
+
Provides-Extra: crewai
|
|
47
|
+
Requires-Dist: crewai>=0.1.0; extra == 'crewai'
|
|
48
|
+
Provides-Extra: langchain
|
|
49
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
|
|
50
|
+
Requires-Dist: langchain>=0.1.0; extra == 'langchain'
|
|
51
|
+
Provides-Extra: openai
|
|
52
|
+
Requires-Dist: openai>=1.0; extra == 'openai'
|
|
53
|
+
Description-Content-Type: text/markdown
|
|
54
|
+
|
|
55
|
+
<div align="center">
|
|
56
|
+
|
|
57
|
+
# 🔍 traceweave
|
|
58
|
+
|
|
59
|
+
### Distributed Tracing & Observability for AI Agents
|
|
60
|
+
|
|
61
|
+
**See exactly what your AI agents are doing. Debug multi-agent systems like a pro.**
|
|
62
|
+
|
|
63
|
+
[](https://pypi.org/project/traceweave/)
|
|
64
|
+
[](https://www.python.org/downloads/)
|
|
65
|
+
[](https://opensource.org/licenses/MIT)
|
|
66
|
+
[](https://pypi.org/project/traceweave/)
|
|
67
|
+
|
|
68
|
+
**English** | [简体中文](README_CN.md) | [日本語](README_JA.md) | [한국어](README_KO.md) | [Español](README_ES.md)
|
|
69
|
+
|
|
70
|
+
[Quick Start](#-quick-start) · [Features](#-features) · [Integrations](#-integrations) · [Dashboard](#-dashboard) · [Examples](#-examples)
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
> **Think of it as Datadog for AI Agents.** Trace every agent decision, tool call, and LLM interaction with beautiful visualizations and zero-config instrumentation.
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
📍 Trace: multi-agent-research id=a3f2c1d8...
|
|
80
|
+
├── ✅ 🔗 multi-agent-research ██████████████████████░░ 12.3s tokens: 8.2k cost: $0.15
|
|
81
|
+
│ ├── ✅ 🤖 planner ████████░░░░░░░░░░░░░░ 3.2s tokens: 2.1k cost: $0.04
|
|
82
|
+
│ │ └── ✅ 🧠 plan-generation ██████░░░░░░░░░░░░░░░░ 2.1s tokens: 1.8k cost: $0.03
|
|
83
|
+
│ ├── ✅ 🤖 researcher ████████████░░░░░░░░░░ 5.1s tokens: 3.4k cost: $0.06
|
|
84
|
+
│ │ ├── ✅ 🔧 web-search ██░░░░░░░░░░░░░░░░░░░░ 0.6s tokens: - cost: -
|
|
85
|
+
│ │ ├── ✅ 🔧 arxiv-search █░░░░░░░░░░░░░░░░░░░░░ 0.3s tokens: - cost: -
|
|
86
|
+
│ │ └── ✅ 🧠 analyze-results ████████░░░░░░░░░░░░░░ 3.1s tokens: 2.8k cost: $0.05
|
|
87
|
+
│ ├── ✅ 🤖 writer ██████████░░░░░░░░░░░░ 4.8s tokens: 1.9k cost: $0.04
|
|
88
|
+
│ │ └── ✅ 🧠 write-report ██████████░░░░░░░░░░░░ 4.2s tokens: 1.9k cost: $0.04
|
|
89
|
+
│ └── ✅ 🤖 reviewer ██████░░░░░░░░░░░░░░░░ 2.4s tokens: 0.8k cost: $0.01
|
|
90
|
+
│ └── ✅ 🧠 review-report ██████░░░░░░░░░░░░░░░░ 2.1s tokens: 0.8k cost: $0.01
|
|
91
|
+
╰── Summary ─────────────────────────────────────────────────────
|
|
92
|
+
⏱ Duration: 12.3s │ 🔢 Spans: 11 │ 📊 Tokens: 8.2k │ 💰 Cost: $0.15
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Why traceweave?
|
|
96
|
+
|
|
97
|
+
Building with AI agents? You've probably experienced:
|
|
98
|
+
|
|
99
|
+
- 🤯 **"Why did my agent do that?"** — No visibility into agent reasoning chains
|
|
100
|
+
- 💸 **"Where are my tokens going?"** — Can't track costs across nested agent calls
|
|
101
|
+
- 🐛 **"Which step failed?"** — Debugging multi-agent pipelines is a nightmare
|
|
102
|
+
- 📊 **"How long does each step take?"** — No performance profiling for agents
|
|
103
|
+
|
|
104
|
+
**traceweave solves all of this with 2 lines of code.**
|
|
105
|
+
|
|
106
|
+
## 🚀 Quick Start
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install traceweave
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from agent_trace import tracer, trace_agent, trace_tool
|
|
114
|
+
from agent_trace.dashboard.tui import print_trace
|
|
115
|
+
|
|
116
|
+
@trace_tool("calculator")
|
|
117
|
+
def add(a: int, b: int) -> int:
|
|
118
|
+
return a + b
|
|
119
|
+
|
|
120
|
+
@trace_agent("math-agent")
|
|
121
|
+
def math_agent(question: str) -> int:
|
|
122
|
+
return add(2, 3)
|
|
123
|
+
|
|
124
|
+
# Trace everything
|
|
125
|
+
with tracer.start_trace("math-task"):
|
|
126
|
+
answer = math_agent("What is 2 + 3?")
|
|
127
|
+
|
|
128
|
+
# Visualize
|
|
129
|
+
print_trace(tracer.get_all_traces()[-1])
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## ✨ Features
|
|
133
|
+
|
|
134
|
+
### 🎯 Zero-Config Auto-Instrumentation
|
|
135
|
+
|
|
136
|
+
Automatically trace OpenAI, Anthropic, and LangChain with a single line:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from agent_trace.integrations import instrument_all
|
|
140
|
+
instrument_all() # That's it! All LLM calls are now traced.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 🤖 Elegant Decorators
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
@trace_agent("researcher") # Trace agent functions
|
|
147
|
+
@trace_tool("web-search") # Trace tool calls
|
|
148
|
+
@trace_llm(model="gpt-4") # Trace LLM calls with token tracking
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 📊 Token & Cost Tracking
|
|
152
|
+
|
|
153
|
+
Automatic token counting and cost estimation for all major models:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
with tracer.start_span("my-llm-call", SpanKind.LLM) as span:
|
|
157
|
+
response = call_llm(prompt)
|
|
158
|
+
span.set_token_usage(
|
|
159
|
+
prompt_tokens=1500,
|
|
160
|
+
completion_tokens=500,
|
|
161
|
+
model="claude-3-sonnet",
|
|
162
|
+
prompt_cost_per_1k=0.003,
|
|
163
|
+
completion_cost_per_1k=0.015,
|
|
164
|
+
)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 🖥️ Beautiful Terminal Dashboard
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
traceweave tui # Live-updating terminal dashboard
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 🌐 Web Dashboard
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
traceweave dashboard # Opens at http://localhost:8420
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Dark-themed, real-time web dashboard with:
|
|
180
|
+
- Interactive trace tree visualization
|
|
181
|
+
- Token usage analytics
|
|
182
|
+
- Cost breakdown per agent/tool
|
|
183
|
+
- Timeline waterfall view
|
|
184
|
+
|
|
185
|
+
### 📤 Export Anywhere
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from agent_trace.exporters import export_json, export_chrome
|
|
189
|
+
|
|
190
|
+
# Save as JSON
|
|
191
|
+
export_json(trace, "my-trace.json")
|
|
192
|
+
|
|
193
|
+
# Export to Chrome DevTools format (open in chrome://tracing)
|
|
194
|
+
export_chrome(trace, "my-trace.chrome.json")
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## 🔌 Integrations
|
|
198
|
+
|
|
199
|
+
### OpenAI
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from agent_trace.integrations.openai_integration import instrument_openai
|
|
203
|
+
instrument_openai()
|
|
204
|
+
|
|
205
|
+
# All OpenAI calls are now traced automatically!
|
|
206
|
+
client = openai.OpenAI()
|
|
207
|
+
response = client.chat.completions.create(
|
|
208
|
+
model="gpt-4",
|
|
209
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Anthropic
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from agent_trace.integrations.anthropic_integration import instrument_anthropic
|
|
217
|
+
instrument_anthropic()
|
|
218
|
+
|
|
219
|
+
# All Anthropic calls are now traced!
|
|
220
|
+
client = anthropic.Anthropic()
|
|
221
|
+
response = client.messages.create(
|
|
222
|
+
model="claude-3-sonnet-20240229",
|
|
223
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
224
|
+
)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### LangChain
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from agent_trace.integrations.langchain_integration import AgentTraceCallbackHandler
|
|
231
|
+
|
|
232
|
+
handler = AgentTraceCallbackHandler()
|
|
233
|
+
chain = prompt | llm | output_parser
|
|
234
|
+
chain.invoke({"input": "..."}, config={"callbacks": [handler]})
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## 📁 Examples
|
|
238
|
+
|
|
239
|
+
| Example | Description |
|
|
240
|
+
|---------|-------------|
|
|
241
|
+
| [Simple Demo](examples/simple_demo.py) | Minimal example — trace in 10 lines |
|
|
242
|
+
| [Multi-Agent Research](examples/multi_agent_demo.py) | 4-agent team with tools, LLM calls, and cost tracking |
|
|
243
|
+
|
|
244
|
+
Run the built-in demo:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
traceweave demo
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## 🏗️ Architecture
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
traceweave/
|
|
254
|
+
├── agent_trace/
|
|
255
|
+
│ ├── core/ # Core tracing engine
|
|
256
|
+
│ │ ├── models.py # Pydantic data models (Span, Trace, TokenUsage)
|
|
257
|
+
│ │ ├── tracer.py # Main tracer with context management
|
|
258
|
+
│ │ ├── span.py # Span context manager
|
|
259
|
+
│ │ ├── context.py # Thread-safe context propagation
|
|
260
|
+
│ │ └── decorators.py # @trace_agent, @trace_tool, @trace_llm
|
|
261
|
+
│ ├── integrations/ # Framework auto-instrumentation
|
|
262
|
+
│ │ ├── openai_integration.py
|
|
263
|
+
│ │ ├── anthropic_integration.py
|
|
264
|
+
│ │ └── langchain_integration.py
|
|
265
|
+
│ ├── dashboard/ # Visualization
|
|
266
|
+
│ │ ├── tui.py # Rich terminal dashboard
|
|
267
|
+
│ │ └── server.py # Web dashboard (single HTML, no build step)
|
|
268
|
+
│ ├── exporters/ # Export formats
|
|
269
|
+
│ │ ├── json_exporter.py
|
|
270
|
+
│ │ └── chrome_exporter.py
|
|
271
|
+
│ └── cli.py # CLI commands
|
|
272
|
+
└── examples/ # Demo scripts
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## 🔑 Key Concepts
|
|
276
|
+
|
|
277
|
+
| Concept | Description |
|
|
278
|
+
|---------|-------------|
|
|
279
|
+
| **Trace** | A complete operation (e.g., "research task"). Contains a tree of spans. |
|
|
280
|
+
| **Span** | A single unit of work (agent call, tool use, LLM request). |
|
|
281
|
+
| **SpanKind** | Type of span: `AGENT`, `TOOL`, `LLM`, `CHAIN`, `RETRIEVER` |
|
|
282
|
+
| **TokenUsage** | Token counts + cost estimation per LLM call |
|
|
283
|
+
|
|
284
|
+
## 📦 Installation
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Core only
|
|
288
|
+
pip install traceweave
|
|
289
|
+
|
|
290
|
+
# With specific integrations
|
|
291
|
+
pip install traceweave[openai]
|
|
292
|
+
pip install traceweave[anthropic]
|
|
293
|
+
pip install traceweave[langchain]
|
|
294
|
+
|
|
295
|
+
# Everything
|
|
296
|
+
pip install traceweave[all]
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
**Requirements:** Python 3.9+
|
|
300
|
+
|
|
301
|
+
## 🤝 Contributing
|
|
302
|
+
|
|
303
|
+
Contributions welcome! Please feel free to submit a Pull Request.
|
|
304
|
+
|
|
305
|
+
1. Fork the repository
|
|
306
|
+
2. Create your feature branch (`git checkout -b feature/amazing`)
|
|
307
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
308
|
+
4. Push to the branch (`git push origin feature/amazing`)
|
|
309
|
+
5. Open a Pull Request
|
|
310
|
+
|
|
311
|
+
## 📄 License
|
|
312
|
+
|
|
313
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
<div align="center">
|
|
318
|
+
|
|
319
|
+
**Built with ❤️ for the AI agent community**
|
|
320
|
+
|
|
321
|
+
If you find traceweave useful, please ⭐ star the repo!
|
|
322
|
+
|
|
323
|
+
</div>
|