pub struct OtelFactorState { /* private fields */ }Expand description
Manages access to the OtelFactor tracing state for the purpose of maintaining proper span parent/child relationships when WASI Otel spans are being created.
Implementations§
Source§impl OtelFactorState
impl OtelFactorState
Sourcepub fn from_prepare_context<T: RuntimeFactors, F: Factor>(
prepare_context: &mut PrepareContext<'_, T, F>,
) -> Result<Self>
pub fn from_prepare_context<T: RuntimeFactors, F: Factor>( prepare_context: &mut PrepareContext<'_, T, F>, ) -> Result<Self>
Creates an OtelFactorState from a [PrepareContext].
If [RuntimeFactors] does not contain an OtelFactor, then calling
OtelFactorState::reparent_tracing_span will be a no-op.
Sourcepub fn reparent_tracing_span(&self)
pub fn reparent_tracing_span(&self)
Reparents the current tracing span to be a child of the last active guest span.
The otel factor enables guests to emit spans that should be part of the same trace as the host is producing for a request. Below is an example trace. A request is made to an app, a guest span is created and then the host is re-entered to fetch a key value.
| GET /... _________________________________|
| execute_wasm_component foo ___________|
| my_guest_span ___________________|
| spin_key_value.get |Setting the guest spans parent as the host is enabled through current_span_context.
However, the more difficult task is having the host factor spans be children of the guest
span. OtelFactorState::reparent_tracing_span handles this by reparenting the current span to
be a child of the last active guest span (which is tracked internally in the otel factor).
Note that if the otel factor is not in your [RuntimeFactors] than this is effectively a
no-op.
This MUST only be called from a factor host implementation function that is instrumented.
This MUST be called at the very start of the function before any awaits.
Trait Implementations§
Source§impl Default for OtelFactorState
impl Default for OtelFactorState
Source§fn default() -> OtelFactorState
fn default() -> OtelFactorState
Auto Trait Implementations§
impl Freeze for OtelFactorState
impl RefUnwindSafe for OtelFactorState
impl Send for OtelFactorState
impl Sync for OtelFactorState
impl Unpin for OtelFactorState
impl UnsafeUnpin for OtelFactorState
impl UnwindSafe for OtelFactorState
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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