Expand description
obs::scope! and obs::context! runtime support — task-local /
thread-local stacks of ScopeFrames, the tail-on-error ring buffer,
and the auto-fill machinery used by EventSchema::project.
Spec 13 §§ 2 + 3, spec 11 § 4.1 (pipeline order steps 3 + 5).
Structs§
- Scope
Frame - One frame on the per-task / per-thread scope stack.
- Scope
Frame Builder - Programmatic builder for pushing an
obs::scope!-shaped frame. - Scope
Guard - RAII guard returned by
obs::scope!andobs::context!. Dropping pops the frame; forScopekind frames where any>= ERRORenvelope was observed, the tail buffer is flushed back through the active observer withsampling_reason = TAIL_ERROR.
Enums§
- Scope
Field - A field declared on
obs::scope!/obs::context!. Field types match the envelope projection contract: trace ids land on the typed envelope slots, labels go intoenv.labels. Spec 13 § 2.1. - Scope
Kind - Whether a frame carries a tail-on-error buffer (
Scope) or is a pure broadcast frame (Context). Spec 13 § 2.2.
Functions§
- active_
correlation - Read the active scope’s correlation pair as
Some((trace_id, span_id))when both have been pushed, otherwiseNone. Walks the stack innermost-first so the deepest set value wins — matches the auto-fill ordering inauto_fill_envelope. - active_
sampled - Inbound sampled decision exposed under the same naming as
active_correlationso callers can grab both with one symmetrical import. Equivalent toinbound_traceparent_sampled. Spec 95 D8-2. - auto_
fill_ envelope - Walk active scopes innermost-first and inject any declared fields
the envelope is missing. Mirrors spec 13 § 2.1: only
None-equivalent envelope slots inherit; explicit values pass through untouched. - inbound_
traceparent_ sampled - Inbound
traceparent.sampleddecision from the outermost (oldest) scope frame, when set. Spec 13 § 6. - mark_
error_ on_ active_ scopes - Mark every active scope frame as having seen an error so the outermost scope’s drop will trigger the tail-on-error flush. Spec 13 § 6.
- pop_
frame_ pub - Public pop helper. See
push_frame_pubfor ownership rules. - push_
frame_ pub - Public push helper for external integrations that own their own
pop (e.g. the tracing bridge pushes on
on_enterand pops onon_exit). External callers MUST pair every call topush_frame_pubwith exactly one call topop_frame_pubin LIFO order — usingScopeFrameBuilder+ the returnedScopeGuardis preferred when the lifetime is RAII-shaped. Spec 94 D7-3. - push_
tail_ buffer - Push an envelope onto the innermost active scope’s tail buffer (if
the scope is a
Scope, not aContext). No-op when no frame is active or the active frame isContext. Spec 13 § 6. - with_
frames_ innermost_ first - Visit every active scope frame innermost-first. Used by
auto_fill_envelopeand byobs::SpanTrace.