Skip to main content

Module telemetry

Module telemetry 

Expand description

Operation correlation and bounded metrics.

Two seams live here, and both exist so that observability can survive a process boundary without this crate acquiring an opinion about where the data goes.

OperationId is the correlation key: one id is minted at an operation boundary and carried by every StudyEvent that operation emits, so a consumer can stitch a trial’s Waiting -> Running -> Complete story back together instead of guessing from timestamps. It is a plain u64 newtype and Copy because StudyEvent is Copy and every emit site depends on that.

record is the metric hook: a closed Metric × Outcome pair, a u64 value and the operation it belongs to, emitted as one structured tracing event on the METRICS_TARGET target. Hydrated study snapshots additionally report their trial, side-state, and pending-finalization counts through three closed-cardinality metrics; those observations use OperationId::NONE because they are not lifecycle work.

§No global state, no subscriber

The only process-global things in this module are the id counter and the active-lease gauge. Nothing here installs a tracing subscriber, allocates a buffer, or spawns a thread — an application installs a subscriber and owns the exporter. Without one, record is a disabled-callsite check and a return.

Structs§

OperationId
Correlates every event emitted by one logical operation.

Enums§

Metric
What a recorded measurement measures.
Outcome
How the measured operation ended.

Constants§

METRICS_TARGET
The tracing target every record event is emitted on.

Functions§

record
Records one measurement as a structured tracing event.