Quick Start
Get TraceKit running in a Python script in under two minutes.
This tutorial shows how to initialize TraceKit, time a function, and log a message in one small script.
1. Install the SDK
pip install tracekit-sdk2. Create app.py
Call tracekit.init() once at startup, decorate a function with @tracekit.trace, and call tracekit.flush() before your short-lived script exits.
app.py
import timeimport tracekit
tracekit.init(output="console", environment="production")
@tracekit.tracedef process_order(order_id: int) -> dict: time.sleep(0.012) return {"id": order_id, "status": "ok"}
tracekit.capture_message("Service started", level="info")process_order(101)tracekit.flush()3. Run the script
terminal
python app.pyExpected output (written to stderr):
output
[TraceKit 2026-11-28 09:56:01] INFO Service started[TraceKit 2026-11-28 09:56:01] SPAN process_order (15.03ms) okWhat just happened
tracekit.init()configured the console sink and installed automatic exception hooks.capture_message()queued an info event.@tracekit.tracetimedprocess_order(101)and queued a span event with its duration in milliseconds.flush()waited for the background worker to write both lines.