Full-stack cross-end debug tracer — NDJSON + readable, scope-filtered, AI-friendly
Project description
tracelink
Full-stack cross-end debug tracer — NDJSON + readable, scope-filtered, AI-friendly.
Install
pip install tracelink
With FastAPI/Starlette support:
pip install tracelink[fastapi]
Quick Start
from tracelink import debug_tracer
debug_tracer.start_scope('delete-work')
debug_tracer.entry('router.py:delete', 'user clicked delete', {'user_id': 123}, scope='delete-work')
debug_tracer.end_scope('delete-work')
Send to the TraceLink board (0.5.0)
The Python sender has HTTP parity with the Node sender: point it at the same
standalone receiver + dashboard (started from the JS package via
npx @qin16778/tracelink board, default port 5174) and Python and Node traces
land on one board, correlated by traceId.
from tracelink import debug_tracer
# non-blocking, fail-safe HTTP sink -> the board
debug_tracer.configure(http_endpoint="http://127.0.0.1:5174/__debug_log")
First-run checklist (or you'll see nothing on the board):
- Start the board first. The receiver lives in the JS package; run
npx @qin16778/tracelink boardbefore your Python process emits. - Enable tracing. It's on when a dev/debug env is set; otherwise force it
with
TRACELINK_ENABLED=1ordebug_tracer.set_enabled(True). - Flush short scripts. Delivery is fire-and-forget on a daemon thread; for a
short-lived script call
sink.flush()before exit (the sink returned byconfigure()), so the last events land.
AI-agent spans (0.5.0)
from tracelink import debug_tracer
async def body():
debug_tracer.blocked('agent.py:sub', 'write outside sandbox denied',
reason='permission denied', data={'path': '/etc/passwd'})
await debug_tracer.span('X-AGENT', 'agent.py:run', 'agent.run', body, scope='agent-run-py')
Spans auto-nest via contextvars (correct across await); the close event
carries real durationMs + async, and blocked / intent set outcome. See
the cross-language flagship demo:
examples/ai-agent.
Features
- AI-agent native:
debug_tracer.span()with autotraceId/parentSpanIdnesting (contextvars),durationMs,async, andoutcome(call/blocked/intent). - Severity levels:
level(debug/info/warn/error) for board filtering + coloring. - Scope-filtered: group related log entries by scope name
- AI-friendly NDJSON: each entry is one JSON line, easy for AI agents to parse
- Zero dependencies: core uses only Python stdlib
- FastAPI/Starlette middleware: plug-and-play HTTP middleware
- Shared board: POST to the JS receiver so Python + Node traces render on one dashboard
CLI
tracelink --port 8080
Links
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 tracelink-0.5.1.tar.gz.
File metadata
- Download URL: tracelink-0.5.1.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fb9ecf2869256f0653447af17e6e42d785f58aef2a51dd22cd083f9822641e5
|
|
| MD5 |
37a4b3b78cef90defde62c5655168bec
|
|
| BLAKE2b-256 |
fe4f3a1edacc2bb56c235c102cdf197d4af003c4772636090b29b692d6b86fff
|
File details
Details for the file tracelink-0.5.1-py3-none-any.whl.
File metadata
- Download URL: tracelink-0.5.1-py3-none-any.whl
- Upload date:
- Size: 42.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4152ff4b8e97518b0d351ce30f4fbc38074570b403528827a67fea1df046a985
|
|
| MD5 |
d931418076d9c6f41a501509c8c57a47
|
|
| BLAKE2b-256 |
4aca65100e46954e81317a0173818024dcbf3daa3ad15fd102d18efdbcecfa37
|