pub struct ScopeFrameBuilder { /* private fields */ }Expand description
Programmatic builder for pushing an obs::scope!-shaped frame.
External crates use this when they need to push a frame whose
fields are decided at runtime (e.g. the tracing bridge stamps
(trace_id, span_id, parent_span_id) from a span extension; the
HTTP middleware stamps the same fields from extracted W3C
traceparent headers).
The builder is consumed by Self::push, which returns a
ScopeGuard that pops the frame on drop. To carry the frame
across an async boundary, use Self::into_frame and feed the
resulting ScopeFrame to
crate::instrumented::Instrument::instrument.
Implementations§
Source§impl ScopeFrameBuilder
impl ScopeFrameBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
New builder defaulting to a Scope frame with a 64-deep
tail-on-error buffer (matches the obs::scope! defaults).
Sourcepub fn context(self) -> Self
pub fn context(self) -> Self
Switch to a Context frame (no tail-on-error buffer cost).
Equivalent to obs::context!.
Sourcepub fn tail_capacity(self, capacity: u16) -> Self
pub fn tail_capacity(self, capacity: u16) -> Self
Override the tail-on-error capacity (only meaningful for
Scope kind; ignored for Context).
Sourcepub fn trace_id(self, value: impl Into<String>) -> Self
pub fn trace_id(self, value: impl Into<String>) -> Self
Set trace_id on the frame so emitted envelopes inherit it
via super::auto_fill_envelope.
Sourcepub fn parent_span_id(self, value: impl Into<String>) -> Self
pub fn parent_span_id(self, value: impl Into<String>) -> Self
Set parent_span_id on the frame.
Sourcepub fn label(self, name: &'static str, value: impl Into<String>) -> Self
pub fn label(self, name: &'static str, value: impl Into<String>) -> Self
Add a (name, value) label pair. The name must be a static
&'static str so it can round-trip through the envelope’s
labels map without an allocation. Spec 13 § 2.1.
Sourcepub fn traceparent_sampled(self, sampled: bool) -> Self
pub fn traceparent_sampled(self, sampled: bool) -> Self
Inbound traceparent.sampled decision. Spec 13 § 6.
Sourcepub fn span_identity(self, name: &'static str, target: &'static str) -> Self
pub fn span_identity(self, name: &'static str, target: &'static str) -> Self
Bridged tracing-span identity for obs::SpanTrace rendering.
Spec 13 § 9.
Sourcepub fn push(self) -> ScopeGuard
pub fn push(self) -> ScopeGuard
Push the frame onto the active task’s scope stack and return the RAII guard. Drop the guard to pop the frame.
Sourcepub fn into_frame(self) -> ScopeFrame
pub fn into_frame(self) -> ScopeFrame
Build the frame without pushing it. Useful when the caller
wants to attach it to a future via
crate::instrumented::Instrument::instrument so the frame
is re-entered on every poll.