Function recorder_from_env
pub fn recorder_from_env() -> Result<(Recorder, Runtime), Error>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:
| Variable | Default | Meaning |
|---|---|---|
DIAL9_ENABLED | false | Master switch for installing telemetry. |
DIAL9_TRACE_DIR | /tmp/dial9-traces | Directory for rotated trace segments. |
DIAL9_ROTATION_SECS | 60 | Rotation period in seconds, measured monotonically from writer start. |
DIAL9_MAX_DISK_USAGE_MB | 1024 | Total on-disk trace budget in MiB. |
DIAL9_MAX_FILE_SIZE_MB | min(100, total / 4) | Per-file trace segment size in MiB. |
DIAL9_GC_DEAD_NAMESPACES | true | Reclaim dead peers’ namespace dirs at startup. |
Supported runtime variables:
| Variable | Default | Meaning |
|---|---|---|
DIAL9_TASK_TRACKING_ENABLED | true | Track tasks spawned through dial9 handles. |
DIAL9_TOKIO_INSTRUMENTATION_ENABLED | true | Install dial9’s Tokio runtime hook instrumentation. |
DIAL9_RUNTIME_NAME | unset | Human-readable runtime name in trace metadata. |
Supported S3 variables (worker-s3 feature required):
| Variable | Default | Meaning |
|---|---|---|
DIAL9_S3_BUCKET | unset | Upload sealed trace segments to this bucket. |
DIAL9_SERVICE_NAME | binary name | Service name used in S3 keys and metadata. |
DIAL9_S3_PREFIX | dial9-traces | S3 object key prefix. |
Supported CPU profiling variables (cpu-profiling feature required):
| Variable | Default | Meaning |
|---|---|---|
DIAL9_CPU_PROFILE_ENABLED | true on Linux with cpu-profiling, false otherwise | Enable CPU stack sampling. |
DIAL9_CPU_SAMPLE_HZ | 99 | CPU sampling frequency in Hz. |
DIAL9_SCHEDULE_PROFILE_ENABLED | true on Linux with cpu-profiling, false otherwise | Enable 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]):
| Variable | Default | Meaning |
|---|---|---|
DIAL9_MEMORY_PROFILE_ENABLED | false | Enable memory allocation sampling. |
DIAL9_MEMORY_SAMPLE_RATE_BYTES | 524288 | Mean bytes between sampled allocations. |
DIAL9_MEMORY_TRACK_LIVESET | false | Track frees for leak detection. |
Supported process resource usage variables (process-resource feature required):
| Variable | Default | Meaning |
|---|---|---|
DIAL9_PROCESS_RESOURCE_USAGE_ENABLED | true on Unix with process-resource, false otherwise | Enable process resource usage sampling from getrusage(RUSAGE_SELF). |
DIAL9_PROCESS_RESOURCE_USAGE_SAMPLE_INTERVAL_MS | 100 | Sampling interval in milliseconds. |
Supported socket accept queue variables (linux-socket feature required):
| Variable | Default | Meaning |
|---|---|---|
DIAL9_SOCKET_ACCEPT_QUEUES_ENABLED | false | Enable TCP accept queue snapshots from Linux sock_diag. |
DIAL9_SOCKET_ACCEPT_QUEUES_SAMPLE_INTERVAL_MS | 400 | Sampling 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):
| Variable | Default | Meaning |
|---|---|---|
DIAL9_TASK_DUMP_ENABLED | false | Capture async task dumps at idle yield points. |
DIAL9_TASK_DUMP_IDLE_THRESHOLD_MS | 10 | Mean 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.