Skip to main content

recorder_from_env

Function recorder_from_env 

pub fn recorder_from_env() -> Result<(Recorder, Runtime), Error>
Available on crate feature dial9 only.
Expand description

Build a recorder and its instrumented Tokio runtime from standard DIAL9_* environment variables.

Hand it straight to the macro: #[dial9::main(config = dial9::recorder_from_env)].

§Per-process namespace isolation

On the disk path, segments are written to a per-process subdirectory {DIAL9_TRACE_DIR}/{boot_id}/, where boot_id is {4-alpha}-{pid} (e.g. qmxz-48291). This keeps processes that share a trace directory from reading and re-uploading each other’s segments. Each process holds an advisory flock on {boot_id}/.lock for its lifetime; on startup it reclaims any sibling namespace whose lock it can acquire (i.e. the owner has exited). Set DIAL9_GC_DEAD_NAMESPACES=false to keep prior runs’ directories instead. Handy locally when comparing traces across runs.

Supported local trace writer variables:

VariableDefaultMeaning
DIAL9_ENABLEDfalseMaster switch for installing telemetry.
DIAL9_TRACE_DIR/tmp/dial9-tracesDirectory for rotated trace segments.
DIAL9_ROTATION_SECS60Rotation period in seconds, measured monotonically from writer start.
DIAL9_MAX_DISK_USAGE_MB1024Total on-disk trace budget in MiB.
DIAL9_MAX_FILE_SIZE_MBmin(100, total / 4)Per-file trace segment size in MiB.
DIAL9_GC_DEAD_NAMESPACEStrueReclaim dead peers’ namespace dirs at startup.

Supported runtime variables:

VariableDefaultMeaning
DIAL9_TASK_TRACKING_ENABLEDtrueTrack tasks spawned through dial9 handles.
DIAL9_TOKIO_INSTRUMENTATION_ENABLEDtrueInstall dial9’s Tokio runtime hook instrumentation.
DIAL9_RUNTIME_NAMEunsetHuman-readable runtime name in trace metadata.

Supported S3 variables (worker-s3 feature required):

VariableDefaultMeaning
DIAL9_S3_BUCKETunsetUpload sealed trace segments to this bucket.
DIAL9_SERVICE_NAMEbinary nameService name used in S3 keys and metadata.
DIAL9_S3_PREFIXdial9-tracesS3 object key prefix.

Supported CPU profiling variables (cpu-profiling feature required):

VariableDefaultMeaning
DIAL9_CPU_PROFILE_ENABLEDtrue on Linux with cpu-profiling, false otherwiseEnable CPU stack sampling.
DIAL9_CPU_SAMPLE_HZ99CPU sampling frequency in Hz.
DIAL9_SCHEDULE_PROFILE_ENABLEDtrue on Linux with cpu-profiling, false otherwiseEnable per-worker scheduler event capture. Requires the CPU profiling setup.

Supported memory profiling variables (memory-profiling feature required; applications must still install the Dial9Allocator from the memory module as their #[global_allocator]):

VariableDefaultMeaning
DIAL9_MEMORY_PROFILE_ENABLEDfalseEnable memory allocation sampling.
DIAL9_MEMORY_SAMPLE_RATE_BYTES524288Mean bytes between sampled allocations.
DIAL9_MEMORY_TRACK_LIVESETfalseTrack frees for leak detection.

Supported process resource usage variables (process-resource feature required):

VariableDefaultMeaning
DIAL9_PROCESS_RESOURCE_USAGE_ENABLEDtrue on Unix with process-resource, false otherwiseEnable process resource usage sampling from getrusage(RUSAGE_SELF).
DIAL9_PROCESS_RESOURCE_USAGE_SAMPLE_INTERVAL_MS100Sampling interval in milliseconds.

Supported socket accept queue variables (linux-socket feature required):

VariableDefaultMeaning
DIAL9_SOCKET_ACCEPT_QUEUES_ENABLEDfalseEnable TCP accept queue snapshots from Linux sock_diag.
DIAL9_SOCKET_ACCEPT_QUEUES_SAMPLE_INTERVAL_MS400Sampling interval in milliseconds.

Supported task dump variables (capture requires the taskdump feature, --cfg tokio_unstable, Linux on aarch64, x86, or x86_64, and futures spawned through a Dial9 spawner, such as dial9::spawn):

VariableDefaultMeaning
DIAL9_TASK_DUMP_ENABLEDfalseCapture async task dumps at idle yield points.
DIAL9_TASK_DUMP_IDLE_THRESHOLD_MS10Mean idle duration for task dump sampling.

See TaskDumpConfig for configuration details.

Missing variables use defaults. Blank, invalid, or non-Unicode values emit a warning and are treated as missing. With DIAL9_ENABLED off, or when the trace writer cannot be created, the returned recorder builds a plain Tokio runtime (the failure is logged at error!).

§Errors

Only if the Tokio runtime cannot be built.