Agent-aware tracing: spans, events, and tool calls for LLM-driven workflows.
Project description
Agent Trace SDK (agtrace)
Agent-aware tracing. Spans, events, and tool calls for LLM-driven workflows.
Why
Generic OpenTelemetry models web servers and database calls. AI agents need a different shape: prompts, tool calls, retries, fallbacks. agtrace borrows OTel's span tree but specializes the kind taxonomy so traces remain useful for debugging agents.
agtrace is the data primitive that apr-app and (eventually) sts-app will emit telemetry into — one trace per PR review, one span per LLM call, one span per tool invocation, all stitched together.
Status
v0.0.1 alpha. In-process tracer + JSONL exporter + CLI dump. OTLP / Jaeger / hosted-collector exporters land in v0.1+.
What v0.0.1 ships
agtrace.tracer.Tracerwith a context-manager API.- Span kinds tuned for AI workloads:
agent·prompt·tool_call·retry·fallback·unknown. - Automatic trace tree (parent / child via
ContextVar— works under asyncio + threads). - Exception handling: an exception inside a span sets
status="error"and records the exception type as an attribute. The exception still propagates. - Configurable exporter: default JSONL appender;
in_memory_tracer()for tests; bring-your-own callable for OTLP / Sentry / Datadog. - CLI:
agtrace dump --from-file traces.jsonlpretty-prints a trace tree.
Usage
from agtrace import default_tracer
tracer = default_tracer() # writes to .agtrace/traces.jsonl
with tracer.span("agent.run", kind="agent", attributes={"agent": "pr-reviewer"}):
with tracer.span("llm.call", kind="prompt") as s:
s.set_attribute("model", "claude-sonnet-4-6")
s.set_attribute("max_tokens", 1024)
# ... call your LLM here ...
s.add_event("rate-limited", attributes={"retry_after": "1.5"})
with tracer.span("tool.call", kind="tool_call") as s:
s.set_attribute("tool", "read_file")
# ... run the tool ...
agtrace version
agtrace dump --from-file .agtrace/traces.jsonl
# Renders a Rich tree:
# agent.run (agent) (124ms)
# agent=pr-reviewer
# llm.call (prompt) (98ms)
# model=claude-sonnet-4-6
# tool.call (tool_call) (12ms)
# tool=read_file
Roadmap
- v0.1 —
OtlpExporter(OTLP/HTTP) so traces ship into Honeycomb / Grafana / Datadog. - v0.1 — context propagation across HTTP boundaries (
agtrace.propagation). - v0.2 — sampling + rate-limiting for production volume.
- v0.3 — integration with
tokencostso eachpromptspan carries the cost in its attributes natively.
Apache-2.0 license. See CHANGELOG.
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 devtrust_agtrace-0.0.2.tar.gz.
File metadata
- Download URL: devtrust_agtrace-0.0.2.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ac931e228e4fb84cafad6b5b63b2202137c3d0982dfc1fe92cc4313c9ac8fd3
|
|
| MD5 |
a07da36b2e41b07ebc9fc36ece244a05
|
|
| BLAKE2b-256 |
181c86e09d9a43f7518ff3ad2df122dd27a5d43a6a97cf98b38a4582768ba0c1
|
Provenance
The following attestation bundles were made for devtrust_agtrace-0.0.2.tar.gz:
Publisher:
release.yml on AbdullahBakir97/DevTrust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
devtrust_agtrace-0.0.2.tar.gz -
Subject digest:
6ac931e228e4fb84cafad6b5b63b2202137c3d0982dfc1fe92cc4313c9ac8fd3 - Sigstore transparency entry: 1486556342
- Sigstore integration time:
-
Permalink:
AbdullahBakir97/DevTrust@c6fc601fa074dc0135f1b9a7b5e46360ec1d9d4e -
Branch / Tag:
refs/tags/devtrust-agtrace-v0.0.2 - Owner: https://github.com/AbdullahBakir97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c6fc601fa074dc0135f1b9a7b5e46360ec1d9d4e -
Trigger Event:
push
-
Statement type:
File details
Details for the file devtrust_agtrace-0.0.2-py3-none-any.whl.
File metadata
- Download URL: devtrust_agtrace-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ee200e3a43ac0919c14f13742cbffd10ffa67e3a27691af204f0427d16e548d
|
|
| MD5 |
66c6dca7e9512a65a34e82d2a47417af
|
|
| BLAKE2b-256 |
e9f47918ff5816c279970699c76461381b916f8efcf8b145ad058f10ea1da0fc
|
Provenance
The following attestation bundles were made for devtrust_agtrace-0.0.2-py3-none-any.whl:
Publisher:
release.yml on AbdullahBakir97/DevTrust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
devtrust_agtrace-0.0.2-py3-none-any.whl -
Subject digest:
6ee200e3a43ac0919c14f13742cbffd10ffa67e3a27691af204f0427d16e548d - Sigstore transparency entry: 1486556514
- Sigstore integration time:
-
Permalink:
AbdullahBakir97/DevTrust@c6fc601fa074dc0135f1b9a7b5e46360ec1d9d4e -
Branch / Tag:
refs/tags/devtrust-agtrace-v0.0.2 - Owner: https://github.com/AbdullahBakir97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c6fc601fa074dc0135f1b9a7b5e46360ec1d9d4e -
Trigger Event:
push
-
Statement type: