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() -> ScopeFrameBuilder
pub fn new() -> ScopeFrameBuilder
New builder defaulting to a Scope frame with a 64-deep
tail-on-error buffer (matches the obs::scope! defaults).
Sourcepub fn context(self) -> ScopeFrameBuilder
pub fn context(self) -> ScopeFrameBuilder
Switch to a Context frame (no tail-on-error buffer cost).
Equivalent to obs::context!.
Sourcepub fn tail_capacity(self, capacity: u16) -> ScopeFrameBuilder
pub fn tail_capacity(self, capacity: u16) -> ScopeFrameBuilder
Override the tail-on-error capacity (only meaningful for
Scope kind; ignored for Context).
Sourcepub fn trace_id(self, value: impl Into<String>) -> ScopeFrameBuilder
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.
Sourcepub fn span_id(self, value: impl Into<String>) -> ScopeFrameBuilder
pub fn span_id(self, value: impl Into<String>) -> ScopeFrameBuilder
Set span_id on the frame.
Sourcepub fn parent_span_id(self, value: impl Into<String>) -> ScopeFrameBuilder
pub fn parent_span_id(self, value: impl Into<String>) -> ScopeFrameBuilder
Set parent_span_id on the frame.
Sourcepub fn label(
self,
name: &'static str,
value: impl Into<String>,
) -> ScopeFrameBuilder
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.
Sourcepub fn traceparent_sampled(self, sampled: bool) -> ScopeFrameBuilder
pub fn traceparent_sampled(self, sampled: bool) -> ScopeFrameBuilder
Inbound traceparent.sampled decision. Spec 13 § 6.
Sourcepub fn span_identity(
self,
name: &'static str,
target: &'static str,
) -> ScopeFrameBuilder
pub fn span_identity( self, name: &'static str, target: &'static str, ) -> ScopeFrameBuilder
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.
Trait Implementations§
Source§impl Debug for ScopeFrameBuilder
impl Debug for ScopeFrameBuilder
Source§impl Default for ScopeFrameBuilder
impl Default for ScopeFrameBuilder
Source§fn default() -> ScopeFrameBuilder
fn default() -> ScopeFrameBuilder
Auto Trait Implementations§
impl Freeze for ScopeFrameBuilder
impl RefUnwindSafe for ScopeFrameBuilder
impl Send for ScopeFrameBuilder
impl Sync for ScopeFrameBuilder
impl Unpin for ScopeFrameBuilder
impl UnsafeUnpin for ScopeFrameBuilder
impl UnwindSafe for ScopeFrameBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request