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

OptionTypeDefaultDescription
outputstr"console"Delivery target: "console", "file:<path>", or "http(s)://...". Unknown strings fall back to "console".
environmentstr"production"Environment name attached to every event.
releasestr | NoneNoneOptional release/version string. Omitted from events when None.
sample_ratefloat1.0Fraction (0.0 to 1.0) of span events to keep. Error and message events are always kept.
ignore_errorslist[type[BaseException] | str] | NoneNone (treated as [])Exception classes or names (e.g. "ValueError") to drop before sending.
before_sendCallable[[dict], dict | None] | NoneNoneHook called with each event dict. Return a dict to keep or None to drop.
debugboolFalseWhen 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:

ResourceLimitBehavior when reached
Background worker threads1 daemon threadStarted lazily on first event
Queue size1,000 eventsDrops new events without blocking
Stack frames per error50 framesKeeps the innermost 50 frames
String field length1,000 charactersTruncated to 1,000 characters
Breadcrumbs per context20 entriesDrops oldest entries
HTTP batch size20 events (or 2s elapsed)Flushes on emit()
HTTP retries3 attemptsExponential backoff (0.5s, 1.0s), then drops
Local viewer ring buffer500 eventsKeeps newest 500 events