TraceKit
A minimal, zero-dependency Python observability SDK — error tracking and performance timing, inspired by Sentry but far smaller.
Package: tracekit-sdk · Import: tracekit · Python: 3.12+ · Dependencies: none (stdlib only)
30-second quickstart
pip install tracekit-sdk # or: uv add tracekit-sdk
import tracekit
tracekit.init(
output="console", # "console" | "file:events.jsonl" | "http://..."
environment="production",
release="1.0.0",
)
# Manual capture
tracekit.capture_message("App started", level="info")
try:
result = 1 / 0
except ZeroDivisionError:
tracekit.capture_exception() # captures current exception automatically
# Performance tracing
@tracekit.trace
def fetch_user(user_id: int) -> dict:
... # your code here
# or with a context manager
with tracekit.span("db.query"):
...
tracekit.flush() # ensure all events are delivered before exit
Output modes
Console (default)
[TraceKit 2026-11-28 10:15:30] ERROR ZeroDivisionError: division by zero app.py:12 in main
[TraceKit 2026-11-28 10:15:30] INFO App started
[TraceKit 2026-11-28 10:15:30] SPAN fetch_user (1.42ms) ok
File (JSONL)
tracekit.init(output="file:events.jsonl")
Each event is one JSON object per line. Use tracekit tail to watch it live:
tracekit tail events.jsonl
HTTP (local viewer or remote ingest)
tracekit.init(output="http://127.0.0.1:8765/ingest")
Start the built-in viewer:
tracekit serve --port 8765
# Open http://127.0.0.1:8765 in your browser — auto-refreshes every 2 s
Full API reference
tracekit.init(...)
| Parameter | Type | Default | Description |
|---|---|---|---|
output |
str |
"console" |
Delivery target (see Output modes above) |
environment |
str |
"production" |
Attached to every event |
release |
str | None |
None |
App version string |
sample_rate |
float |
1.0 |
Fraction of span events to keep (0.0–1.0); errors are always kept |
ignore_errors |
list |
[] |
Exception classes or name strings to silently drop |
before_send |
callable | None |
None |
Called with every event dict; return None to drop |
debug |
bool |
False |
Print internal SDK errors to stderr |
Automatic exception capture
After init(), unhandled exceptions are captured automatically:
# Main thread — via sys.excepthook
# Worker threads — via threading.excepthook
# asyncio tasks — call once after creating your loop:
tracekit.install_asyncio_hook(loop)
Scope enrichment
tracekit.set_user(id="42", email="alice@example.com")
tracekit.set_tag("region", "eu-west-1")
tracekit.add_breadcrumb("Payment initiated", category="checkout")
All subsequent events from the same thread / async task carry these fields.
Performance tracing
# Decorator — sync and async both supported
@tracekit.trace
async def process_order(order_id: int) -> None: ...
@tracekit.trace(name="custom.span.name")
def expensive_query() -> list: ...
# Context manager
with tracekit.span("external.api.call"):
response = requests.get(url)
Filtering and scrubbing
def drop_health_checks(event: dict) -> dict | None:
if event.get("message") == "GET /health":
return None # drop
return event # keep
tracekit.init(
before_send=drop_health_checks,
ignore_errors=[ConnectionResetError, "TimeoutError"],
sample_rate=0.1, # keep 10 % of spans
)
Fields named password, secret, token, api_key, authorization, cookie etc. are automatically replaced with [Filtered] before any event leaves the process.
Python logging integration
import logging
from tracekit.integrations.logging import TraceKitHandler
tracekit.init(...)
logging.getLogger().addHandler(TraceKitHandler())
logging.error("Something broke") # → error event
logging.warning("Slow query: 2.3 s") # → breadcrumb
logging.info("User signed in") # → breadcrumb
CLI tools
tracekit tail events.jsonl # follow a JSONL file live
tracekit serve --port 8765 # start the HTML viewer
Architecture
Your app
│
├─ tracekit.capture_exception / capture_message
├─ @tracekit.trace / tracekit.span()
└─ sys/threading/asyncio hooks
│
▼
Client
├─ apply_filters() ← sample_rate, ignore_errors, scrubbing, before_send
└─ Transport.enqueue() ← non-blocking, drops if queue full (max 1000)
│
▼ (single daemon thread)
Sink.emit()
├─ ConsoleSink → stderr (ANSI colour)
├─ FileSink → JSONL file (open/write/close per event)
└─ HttpSink → POST batches ≤20 events, retry ×3 with backoff
Resource limits (PRD §1.10)
| Resource | Limit |
|---|---|
| Background threads | 1 daemon thread |
| Event queue | 1 000 slots (drop when full, never block) |
| Stack frames per error | 50 (innermost kept) |
| String field length | 1 000 chars (truncated with …) |
| Breadcrumbs per context | 20 (oldest dropped) |
| HTTP batch size | 20 events |
| HTTP retry attempts | 3 × exponential backoff (0.5 → 1.0 → 2.0 s) |
| Viewer ring buffer | 500 events |
Development
git clone https://github.com/yourname/tracekit
cd tracekit
uv sync --dev
uv run pytest -v # run tests
uv run ruff check . # lint
uv build # build wheel → dist/
Note: Phase 6 network tests use loopback TCP — run
uv run pytest -voutside any sandbox environment that restrictsbind()/connect().
Releasing
Releases are published automatically to PyPI via GitHub Actions Trusted Publishing when a GitHub release is published:
- Bump
versioninpyproject.toml. - Run
uv lockto update the lockfile. - Commit the changes:
git commit -am "Release vX.Y.Z". - Tag the commit:
git tag vX.Y.Z. - Push the commit and tag:
git push && git push --tags. - Create and publish a GitHub Release for tag
vX.Y.Z.
License
MIT
Metadata
Release files for tracekit-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tracekit_sdk-0.1.0.tar.gz | 49.4 kB | Without provenance | Details for tracekit_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tracekit_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tracekit_sdk-0.1.0-py3-none-any.whl |
Total release size: 79.4 kB
Release files / tracekit_sdk-0.1.0.tar.gz
| Download URL | tracekit_sdk-0.1.0.tar.gz |
|---|---|
| Size | 49.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8354535679992eb1a65811d3e2466eae48e8a7e3e94b7c919bd6eb5d78c2a4e
|
|
BLAKE2b-256 checksum How to use checksums |
c1e056494baaeab14e7406547257571a1161707b7f0decd44236ab7dcdd3fa1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / tracekit_sdk-0.1.0-py3-none-any.whl
| Download URL | tracekit_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb29d7667f152ba8e96988ecc45796568f6b1d5fef63c08919d41c50e5b41d42
|
|
BLAKE2b-256 checksum How to use checksums |
1e9315901ebae2dc0b22ab2f7c90a52fa2ac8ce5b4a234190a24027fc57a0ee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for tracekit-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.