Skip to content

Logging and observability

What fastsandbox tells you about its work: the loggers it writes to, the streams a program can read, and what is kept out of them. It installs no logging handler of its own, except in the command line, and sends nothing anywhere: no telemetry, no OpenTelemetry.

Loggers

Logger Level What
fastsandbox WARNING A daemon of an API version outside the range, connected with version_policy="warn"; a removal that failed after an error, in a block of the client, a launch, a stream or an SSH tunnel
fastsandbox.task.<name> WARNING A credential the daemon withholds from the sandbox of a run; a removal that failed at the end of a run
fastsandbox.task.<name> INFO What the task logs with ctx.log(), as task [sandbox] message
fastsandbox.task.<name> DEBUG The progress a task reports with ctx.report_progress()
fastsandbox.native.<crate>.<module> WARNING What the crates of docker-sandbox warn of: a lease dropped without shutdown, whose sandbox stays; a session the daemon closed that cannot be opened again; the sandbox of a creation given up that cannot be deleted; a kit package made for another version of sbx
fastsandbox.native.<crate>.<module> INFO, DEBUG The deletion of the sandbox of a creation given up; each request to the daemon, with its status and duration (fastsandbox.native.docker_sandbox.transport)

Configure them as any logger of the standard library:

logging.basicConfig(level=logging.INFO)

The command line logs at WARNING, or INFO with -v, on standard error.

The crates underneath log through the tracing library of Rust. The native extension hands their events to logging, under fastsandbox.native, then the module of the event: fastsandbox.native.docker_sandbox.transport for the requests to the daemon. The fields of an event follow its message, as in sandbox="job-1". To see the requests a program makes:

logging.getLogger("fastsandbox.native").setLevel(logging.DEBUG)

The level of each of these loggers is read the first time it logs, then again at each connect(): configure logging before connecting. A record the crates log once the interpreter exits is dropped. The warning of an API version outside the range comes from the fastsandbox logger alone.

Streams and reports

To follow Read
The progress of a run on_progress= of app.run(), fed by ctx.report_progress()
The events of the daemon: sandboxes created, stopped, removed, ports, policy changes client.events.subscribe()
The output of an agent, event by event ctx.agent.stream()
The progress of a creation or an image pull client.sandboxes.create_stream(), client.images.pull_stream()
The hosts sandboxes reached or were refused client.policy.log()
What a launch did lease.report, ctx.lease.report: kits, rules, keys left out, never a value
The metrics of a sandbox sandbox.vm_metrics(), in the Prometheus format
The state of the daemon client.daemon.disk_usage(), diagnostics()

Events and prompts and Stream agent events show them in use.

Telling runs apart

Each run has an identifier, ctx.run_id, a random hexadecimal string, and its sandbox a name and an identifier, which the warnings of a failed removal give. fastsandbox does not put the run identifier in the name of the sandbox or in its logs: log it yourself with ctx.log() to tie a run to what it did.

What is kept out, and what is not

  • The values of keys are kept out of Python: a ProxiedKey and Keys show the names of their variables only, and a report never holds a value. Secrets in models are Pydantic SecretStr.
  • Nothing is redacted from what a sandbox prints: the output of a command, the message of a CommandFailedError, which holds its last lines, and what an agent writes can hold any value the sandbox can read, the variables of env= and the token of an MCP server of the host included. Do not log them where a secret must not go.

Next