Struct OperationId
pub struct OperationId(/* private fields */);Expand description
Correlates every event emitted by one logical operation.
An operation is one unit of lifecycle work a worker performs and can be
pointed at in a log: one ask that creates and starts a trial, one resume,
one finalization, one optimize run, one study open. Every event that unit
emits carries the same id, which is what turns a stream of independent
lifecycle records into a trace.
§Invariants
- Unique within a worker, not globally. Ids come from a process-local
counter that restarts at 1 every time the process does. Two workers — two
threads with different
WorkerIds, two processes, the same process restarted — will each hand outOperationId(1). The correlation key a downstream consumer must use is therefore the pair(worker, operation). A dashboard that groups byoperationalone silently merges unrelated work from different workers, and it will look plausible while doing it. NONEis the reserved zero id and is never returned bynext. It means “this event belongs to no operation this handle is tracking” — an honest gap, not a correlation.Copyand 8 bytes wide, becauseStudyEventisCopyand its emit sites pass it by value.
use atune_core::telemetry::OperationId;
let first = OperationId::next();
let second = OperationId::next();
assert_ne!(first, second);
assert!(!first.is_none());
assert!(OperationId::NONE.is_none());Implementations§
§impl OperationId
impl OperationId
pub const NONE: Self
pub const NONE: Self
The absent operation: no operation is being tracked for this event.
Reserved, never minted. An emit site that genuinely cannot know its operation — a trial finalized by a handle that did not start it, for instance — uses this rather than minting a fresh id, because a fresh id would claim a correlation that does not exist.
pub fn next() -> Self
pub fn next() -> Self
Mints the next process-local operation id.
Call this once at an operation boundary and carry the result through to every event the operation emits. Minting per event defeats the whole purpose: the ids would be unique and correlate nothing.
The counter wraps after 2^64 operations, which at a billion operations
a second is roughly 584 years of continuous uptime; the wrapped zero is
skipped so a wrapped counter can never masquerade as
NONE.
Trait Implementations§
§impl Clone for OperationId
impl Clone for OperationId
§fn clone(&self) -> OperationId
fn clone(&self) -> OperationId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more