Expand description
Typed runtime and policy observations, separate from effect replay records.
Witness receives facts and ObservationLog retains a bounded trace.
Optional timestamps come from a host-supplied Clock, not replay identity.
use rig_core::observe::ObservationLog;
let log = ObservationLog::with_capacity(128);
log.finalize();
assert!(log.trace().finalized);Structs§
- Adapter
Analysis - Analysis-only response metadata. Never use identifiers as operation join keys.
- Adapter
Context - A caller-supplied witness and logical operation identity.
- Adapter
Error Envelope - Original provider error-envelope fields, separate from Rig retry classification.
- Adapter
Observation - One fact about a provider operation, independently of its effect record.
- Adapter
Usage - The counters of the
Usagethe decoder normalized into the reply’s end, observed once when the reply ends; an attempt that fails before its end observes none. Unreported isNone. - Adapter
Verdict - Sparse provider metadata: a present field supersedes its previous value.
- Emitter
- Stable emitter name and optional version.
- Observation
- One observed fact.
- Observation
Log - The bounded in-memory sink, in one of two shapes. A capture
(
Self::with_capacity, the default) keeps the firstcapacityfacts and counts the rest as dropped: the trace is a complete prefix or says how much of the session it missed, which is what a comparison wants. A ring (Self::ring) keeps the lastcapacityfacts and counts what it let go: a long-running host always sees its recent past, which is what a dashboard wants. Either waySelf::draintakes what is kept and starts over, so a host that exports periodically never fills up. - Observation
Sink - Where a payload projector writes its observation facts.
- Observation
Trace - The serializable trace a sink produces: the analysis artifact.
- Reason
- A structured reason: a stable code and an optional free-text detail. The code is what a comparison keys on; the detail is for a reader.
- Subject
- What an observation is about. Every field is optional because facts
exist before an effect has an id (a gate decides a pending intent), and
some have no effect at all (a run ending). Correlation never depends on
a runtime handle:
scopeis the program’s serde id,orderthe driver’s dispatch order,effect/parentthe record’s ids.
Enums§
- Action
- The fact: one the provider request boundary saw, or a host’s own
(
Action::Host). - Adapter
Ending - How a provider attempt closed, distinct from the run’s ending.
- Adapter
Error Boundary - Boundary identified by the adapter’s original typed error, not its message.
- Adapter
Event - Metadata from the provider boundary. Request/response bodies are not included.
- Stage
- Where a fact was seen: the handler side (the provider request boundary), or the host.
Constants§
- DEFAULT_
CAPACITY - The default capacity of an
ObservationLog.
Traits§
- Clock
- A host-owned monotonic clock: what a sink stamps
Observation::atfrom. rig-core reads no clock itself; a test supplies a counter. - Host
Action - A host-defined action: a named, serde-typed fact a host policy emits
through
Action::Host. The kind is declared once per type, so a trace names every host fact and a consumer deserializes it back. - Witness
- Where observations go: the seam a driver and a host emit through. A
witness is shared, so it takes
&self; it must never block the caller.
Functions§
- diagnostic_
url_ secrets - The secrets a URL carries for diagnostic redaction: userinfo and known credential query parameters, origin-form request URIs included. The returned values are secrets: keep them runtime-only and never write them into a diagnostic or an artifact.
- scrub_
diagnostic - Bounds diagnostic text and removes control characters. Known credentials or credential markers redact the whole message; oversized messages are replaced rather than truncated to a potentially sensitive prefix.