Your First Error
See how TraceKit captures a real bug in a small Python script without changing your error handling.
TraceKit does not replace Python tracebacks. When a real bug happens, TraceKit records the error event and span status, then lets Python's original exception propagate normally.
A realistic script with a bug
Suppose you are processing a list of customer orders, and one order dictionary is missing the "qty" key.
orders.py
import timeimport tracekit
tracekit.init(output="console", environment="test")
orders = [ {"id": 1, "price": 100, "qty": 2}, {"id": 2, "price": 250, "qty": 1}, {"id": 3, "price": 80}, # missing "qty" {"id": 4, "price": 40, "qty": 5},]
@tracekit.tracedef calculate_total(order: dict) -> int: time.sleep(0.05) return order["price"] * order["qty"]
@tracekit.tracedef process_all() -> int: total = 0 for order in orders: total += calculate_total(order) return total
print("Grand total:", process_all())Run it
terminal
python orders.pyExpected output:
output
[TraceKit 2026-11-28 09:30:49] SPAN calculate_total (51.07ms) ok[TraceKit 2026-11-28 09:30:50] SPAN calculate_total (55.03ms) ok[TraceKit 2026-11-28 09:30:50] ERROR KeyError: 'qty' orders.py:16 in calculate_total[TraceKit 2026-11-28 09:30:50] SPAN calculate_total (57.79ms) error[TraceKit 2026-11-28 09:30:50] ERROR KeyError: 'qty' orders.py:16 in calculate_total[TraceKit 2026-11-28 09:30:50] SPAN process_all (164.72ms) errorTraceback (most recent call last): File "orders.py", line 25, in <module> print("Grand total:", process_all()) ...KeyError: 'qty'Reading the output
- Orders 1 and 2 succeeded, so
calculate_totalrecordedokspans. - Order 3 raised
KeyError: 'qty'atorders.py:16. - Both
@tracewrappers recorded the exception and marked their spans aserror, while the originalKeyErrorstill reached Python's top-level traceback.