How the SDK behaves in real process models: servers that fork, workers that exec, build steps, and processes with no DSN configured. Everything on this page is a contract the SDK keeps, not an implementation detail.
There are three ways a process gets its client, in order of coverage:
| Mode | Instrumentation coverage | Use when |
|---|---|---|
wildedge run -- <cmd> |
Guaranteed: patches before any user code runs | You control the start command |
wildedge.init(...) at startup |
Everything created after the call | You control application code |
| Lazy, from the first module-level call | Best effort: only what is created afterwards | Manual tracking only |
All three produce the same thing: one process-wide default client that
wildedge.span(), wildedge.register_model() and the rest delegate to.
init() without dsn, or with the DSN that client already uses, reuses
whatever client already exists, so code written for in-process init runs
unchanged under wildedge run.
The lazy mode configures itself from the environment: WILDEDGE_DSN,
WILDEDGE_INTEGRATIONS, WILDEDGE_HUBS. Unset integration variables mean
nothing is patched; auto-instrumentation is always opt-in.
Without WILDEDGE_DSN, the client is a no-op: no background threads, no
network, no patched frameworks, every event dropped. This is a supported mode
for development and CI, not an error; the SDK logs one INFO line per process
and stays quiet. Leave the SDK integrated and unset the variable wherever you
do not want telemetry (local dev, test runs, build and migration steps).
Under wildedge run, a missing DSN warns on stderr and your program runs
untracked. Telemetry failing must not take production down; that is the
default policy.
| Flag | Description |
|---|---|
--integrations |
Comma-separated runtime integrations, such as llama_cpp, onnx, or openai; default: all |
--hubs |
Download tracking via huggingface or torchhub |
--print-startup-report |
Print activation status for each integration |
--strict-integrations |
Exit with 121 if a requested integration cannot be instrumented |
--strict |
Exit on bootstrap failure; see the exit codes below |
--attachments |
Enable upload of explicitly supplied attachments |
--no-propagate |
Scrub run-scoped environment variables after initialization |
Use llama_cpp for the llama-cpp-python runtime. The older name gguf is
accepted as a compatibility alias in Python, CLI, and environment settings.
The recorded model format remains gguf.
wildedge run --strict inverts the failure policy for deployments where
running unobserved is worse than not running. Bootstrap failures then
terminate the process before your program starts:
| Exit code | Meaning |
|---|---|
| 120 | Configuration error (missing or invalid DSN) |
| 121 | A requested integration could not be instrumented (requires --strict-integrations) |
| 122 | Internal bootstrap error |
--strict-integrations is its own opt-in and exits with 121 on failure even
without --strict; asking for it is the request to fail.
wildedge run prepends wildedge/autoload/ to PYTHONPATH and replaces
itself with your command. Every Python interpreter that starts under it runs
the bundled sitecustomize.py, which bootstraps the runtime before any user
code. Two mechanisms make this safe across worker models:
- Fresh interpreters (exec or spawn) bootstrap themselves via sitecustomize;
a
sys.modulesmarker prevents double initialization within one interpreter. - Forked children inherit the parent's initialized runtime, and
os.register_at_forkhooks stop the SDK's background threads before each fork and start fresh ones in parent and child afterward, so forked workers transmit normally instead of inheriting dead threads.
How that plays out on common servers:
| Server | Worker model | Behavior under wildedge run |
|---|---|---|
gunicorn (sync/gthread, with or without preload_app) |
fork from master | Master bootstraps once; each worker gets fresh SDK threads via the at-fork hooks |
uvicorn (--workers, --reload) |
spawn / exec | Every worker is a fresh interpreter and bootstraps itself |
| granian | spawned worker processes | Each worker bootstraps itself |
| daphne | single process | One bootstrap, nothing special |
| waitress | single process, thread pool | One bootstrap; the client is thread-safe |
| celery (prefork pool) | fork from master | Same as gunicorn: at-fork hooks restart threads per worker |
For managed platforms, wrap only the serving command. Build steps and
migrations run in separate processes that gain nothing from telemetry; leave
them unwrapped or unset WILDEDGE_DSN there.
- Framework patches are installed at most once per process. One live client
owns process-wide auto-instrumentation. When another client enables an
integration or hub while that owner is live, it logs a warning and
automatic events keep going to the owner's project. The new client still
sends its manual tracking. With
wildedge run --strict-integrations, the conflict raisesRuntimeErrorinstead. Manual tracking does not claim ownership. init()reuses the live default client unless you pass adsnfor a different project, so the CLI-installed client and application code share one client instead of racing.- Trace and span correlation lives in contextvars at module level, not on a
client. Auto-instrumented events emitted inside
wildedge.trace(...)/wildedge.span(...)blocks correlate into the same trace no matter which client emits them.
Sequential replacement is supported. Finish any in-flight work and close the old SDK client before initializing its replacement. Enable integrations and hubs explicitly on the replacement: previously enabled integrations do not carry over. Factory patches resolve the new owner without being installed again. Buffered HuggingFace download provenance is scoped to its owner session and does not carry over to another project.
first = wildedge.init(dsn=dsn, integrations=["onnx"])
session = ort.InferenceSession("model.onnx")
# Run and finish work with session.
first.close(timeout=10)
second = wildedge.init(dsn=other_dsn, integrations=["onnx"])
session = ort.InferenceSession("model.onnx") # create after replacement initExisting model objects, provider clients, model handles and in-flight streams
remain bound to the original client; they are not automatically transferred to
another project. Recreate auto-instrumented models/provider clients after
initializing the replacement. Attempts to emit inference/error telemetry through
a closed client are dropped with a one-time warning; application inference can
still run. Simply changing the default client does not change instrumentation
ownership. Repeated close() calls are harmless.
init() replaces a closed default even when no explicit dsn is supplied,
reading the new client's configuration from the environment. If initialization
fails (including an ownership conflict), a newly created client is closed and
the existing default is preserved.
wildedge doctor answers "will events actually flow from this machine"
before you rely on it:
wildedge doctor --integrations all --send-test-event --format json--send-test-eventsends one real span event through the full pipeline (DSN auth, ingest endpoint, batch protocol) and reports the server's response, which a TCP-level--network-checkcannot do.- The report includes an
environmentsection with everyWILDEDGE_*variable the runtime reads, plus whether the autoload dir is onPYTHONPATH. - Exit codes: 0 all pass, 1 configuration or dependency failure, 2 the config is fine but the ingest endpoint is unreachable or rejecting.
--format json makes the output machine-readable; pasting it into an issue
or an AI assistant is the intended debugging flow.
By default, wildedge run leaves its WILDEDGE_* variables in the
environment so that exec'd children (reload workers) can bootstrap. Pass
--no-propagate to have each bootstrapped process scrub the run-scoped
variables after initialization, keeping them away from nested subprocesses
you spawn yourself.