Configuration
All options accepted by tracekit.init(), their types, and defaults.
Configure TraceKit once at startup by calling tracekit.init(). Calling init() again shuts down the previous client's background worker and replaces it.
tracekit.init() options
| Option | Type | Default | Description |
|---|---|---|---|
output | str | "console" | Delivery target: "console", "file:<path>", or "http(s)://...". Unknown strings fall back to "console". |
environment | str | "production" | Environment name attached to every event. |
release | str | None | None | Optional release/version string. Omitted from events when None. |
sample_rate | float | 1.0 | Fraction (0.0 to 1.0) of span events to keep. Error and message events are always kept. |
ignore_errors | list[type[BaseException] | str] | None | None (treated as []) | Exception classes or names (e.g. "ValueError") to drop before sending. |
before_send | Callable[[dict], dict | None] | None | None | Hook called with each event dict. Return a dict to keep or None to drop. |
debug | bool | False | When True, internal SDK errors print to stderr. |
Example configuration
config_example.py
import tracekit
def strip_local_spans(event: dict) -> dict | None: if event.get("environment") == "local" and event.get("type") == "span": return None return event
tracekit.init( output="file:events.jsonl", environment="staging", release="1.2.0", sample_rate=0.5, ignore_errors=[KeyboardInterrupt, "TimeoutError"], before_send=strip_local_spans, debug=False,)Resource limits
TraceKit enforces fixed caps to protect host application memory and CPU:
| Resource | Limit | Behavior when reached |
|---|---|---|
| Background worker threads | 1 daemon thread | Started lazily on first event |
| Queue size | 1,000 events | Drops new events without blocking |
| Stack frames per error | 50 frames | Keeps the innermost 50 frames |
| String field length | 1,000 characters | Truncated to 1,000 characters |
| Breadcrumbs per context | 20 entries | Drops oldest entries |
| HTTP batch size | 20 events (or 2s elapsed) | Flushes on emit() |
| HTTP retries | 3 attempts | Exponential backoff (0.5s, 1.0s), then drops |
| Local viewer ring buffer | 500 events | Keeps newest 500 events |