Skip to main content
The entire public API is deliberately small — everything is importable from the top-level package:
Every call is a safe no-op when the recorder is inactive — you can leave instrumentation in production code unconditionally.

enable()

Start recording this process. Idempotent — calling it twice does nothing the second time. Completes in under 5 ms (enforced by a test).
root
str | Path | None
default:"None"
Where to place (or find) the .slomo/ data directory. Defaults to auto-detection from the current working directory. The directory containing .slomo/ becomes the project root — the boundary auto-tracing uses to decide what counts as project code.
labels
dict[str, str] | None
default:"None"
Arbitrary key-value labels stored in the session’s metadata, e.g. labels={"service": "checkout", "env": "staging"}. Visible in slomo session show.
hooks
bool
default:"True"
Install the automatic hooks (auto-trace, exceptions, snapshots, SQL, HTTP, logging). With hooks=False only explicit @track/snapshot()/event() calls record.

disable()

Stop recording and finalize the current session (writes session.finished, flushes, uninstalls hooks). Normally unnecessary — sessions finalize automatically at interpreter exit. Use it when a long-lived process wants to close its recording early.

track

Decorator recording a span per call: function.enter (args) and function.exit (result, duration_ns), with any escaping exception recorded and re-raised. Works on sync functions, async functions, generators, and async generators; span context propagates across await.
capture_args
bool
default:"True"
Record positional and keyword arguments on enter.
capture_result
bool
default:"True"
Record the return value on exit. (Results that are None are omitted.)
name
str | None
default:"None"
Span label; defaults to the function’s __qualname__.
Functions carrying @track are registered so auto-tracing never records them twice. When the recorder is disabled the wrapper short-circuits to the original function with near-zero overhead. Usage guide: Manual instrumentation.

snapshot()

Record an explicit variable.snapshot event.
label
str | None
default:"None"
Positional-only label shown in slomo vars and replay, e.g. "before-retry".
variables
Any
Keyword arguments to capture. Values pass through truncation and redaction before being written.

event()

Record a custom event.
name
str
required
Event name, e.g. "cache.warmed". Searchable via slomo search.
severity
str
default:"info"
One of debug, info, warning, error, critical. Unknown strings fall back to info. Severity warning+ appears in slomo timeline --errors.
payload
Any
Arbitrary keyword payload, truncated and redacted like all captures.

install_hooks()

Re-run hook installation. The HTTP hooks attach to requests/httpx only if those modules are already imported — if you import one after enable(), call this to attach retroactively:
No-op if the recorder is inactive. Already-installed hooks are not duplicated.

flush()

Block until every buffered event is on disk (with fsync). The writer thread normally flushes every 0.5 s and at exit; call this before exit paths that skip interpreter teardown (os._exit(), exec*) or before reading .slomo/ from the same process.

__version__

Stability

These seven names are the supported surface. Modules under slomo._core and other internals are private and may change without notice.