Skip to main content

ScopeFrameBuilder

Struct ScopeFrameBuilder 

Source
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

Source

pub fn new() -> ScopeFrameBuilder

New builder defaulting to a Scope frame with a 64-deep tail-on-error buffer (matches the obs::scope! defaults).

Source

pub fn context(self) -> ScopeFrameBuilder

Switch to a Context frame (no tail-on-error buffer cost). Equivalent to obs::context!.

Source

pub fn tail_capacity(self, capacity: u16) -> ScopeFrameBuilder

Override the tail-on-error capacity (only meaningful for Scope kind; ignored for Context).

Source

pub fn trace_id(self, value: impl Into<String>) -> ScopeFrameBuilder

Set trace_id on the frame so emitted envelopes inherit it via super::auto_fill_envelope.

Source

pub fn span_id(self, value: impl Into<String>) -> ScopeFrameBuilder

Set span_id on the frame.

Source

pub fn parent_span_id(self, value: impl Into<String>) -> ScopeFrameBuilder

Set parent_span_id on the frame.

Source

pub fn label( self, name: &'static str, value: impl Into<String>, ) -> ScopeFrameBuilder

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.

Source

pub fn traceparent_sampled(self, sampled: bool) -> ScopeFrameBuilder

Inbound traceparent.sampled decision. Spec 13 § 6.

Source

pub fn span_identity( self, name: &'static str, target: &'static str, ) -> ScopeFrameBuilder

Bridged tracing-span identity for obs::SpanTrace rendering. Spec 13 § 9.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ScopeFrameBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ScopeFrameBuilder

Source§

fn default() -> ScopeFrameBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.