Available on crate feature
instance only.Expand description
Instance info: facts fixed when this process started, answering “which running copy is this?” when several run at once. Put the instance id in every log line, audit record, and metric so events from two processes are never mixed up.
use sys_lib::Instance;
let me = Instance::start();
println!("{me}"); // 01J9ZQ4M8T6Y2K5V3W1X7R0B9C web-01 pid 48213 up 0s
eprintln!("instance={} event=boot", me.id()); // tag every log line
assert!(std::ptr::eq(me, Instance::start())); // one instance per processStructs§
- Instance
- The running copy of this program. Created once per process by
Instance::start; every caller sees the same value. - Instance
Id - An instance id: a 128-bit ULID, displayed as 26 Crockford base32 characters.
Functions§
- current
- The instance created by
Instance::start, orNonebefore the first call.