Troubleshooting & FAQ

Solutions for common issues when using TraceKit.

Events are missing when my script exits

TraceKit delivers events asynchronously on a background daemon thread. If your script finishes immediately after capture_message() or @trace, the process may exit before the worker drains the queue.

Fix: Call tracekit.flush() (or tracekit.shutdown()) at the end of short-lived scripts.

python -m tracekit fails

TraceKit does not define a __main__.py module, so python -m tracekit raises:

output
No module named tracekit.__main__; 'tracekit' is a package and cannot be directly executed

Fix: Run the tracekit CLI command directly (tracekit tail ... or tracekit serve ...), or with uv run tracekit ....

HttpSink didn't send my single test event right away

HttpSink buffers up to 20 events or waits until 2 seconds have passed when the next event arrives.

Fix: For testing tracekit serve with a small script, either send 20 events or check that HttpSink flushes when the 2-second interval is reached on subsequent events.

Why does my sample_rate=0.0 still print errors?

sample_rate only applies to span events (performance timings). Error events and capture_message() events are always kept so you don't miss crashes. To ignore specific exceptions, pass ignore_errors=[...] to tracekit.init().

Does TraceKit work in multi-threaded or async apps?

Yes. Scope (set_user, set_tag, add_breadcrumb) uses contextvars with copy-on-write updates, so each thread and asyncio task keeps its own isolated copy. Remember to call tracekit.install_asyncio_hook(loop) to capture unhandled asyncio task exceptions.