Struct Dial9TokioHandle
pub struct Dial9TokioHandle { /* private fields */ }dial9 only.Expand description
Tokio handle for spawning instrumented tasks.
Spawned futures are wrapped with wake-event tracking and, when configured,
task dump capture while telemetry is live on this handle. Otherwise they
spawn plainly. Obtain one for the current runtime with
current. To spawn onto a specific runtime from any thread,
use spawn_in.
This handle only spawns. For recording and control, use Dial9Handle.
Implementations§
§impl Dial9TokioHandle
impl Dial9TokioHandle
pub fn current() -> Dial9TokioHandle
pub fn current() -> Dial9TokioHandle
Handle that spawns on the current tokio runtime (like tokio::spawn).
Wraps spawned futures with Dial9 instrumentation when the current thread is owned by a live dial9 runtime, otherwise spawns plainly.
pub fn disabled() -> Dial9TokioHandle
pub fn disabled() -> Dial9TokioHandle
Inert handle: spawn falls back to [tokio::spawn]
without Dial9 instrumentation.
pub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output> ⓘ
pub fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output> ⓘ
Spawn an instrumented future.
On an enabled handle the future is wrapped with wake-event tracking and,
when configured, task dump capture. The task runs on this handle’s
runtime, the current one for current, or the specific
runtime the handle was built for.
§Panics
For a current-runtime handle, panics if called outside
a tokio runtime context (same as [tokio::spawn]).
pub fn spawn_with<F, S>(
&self,
future: F,
spawn_fn: impl FnOnce(TracedFuture<F>) -> S,
) -> S
pub fn spawn_with<F, S>( &self, future: F, spawn_fn: impl FnOnce(TracedFuture<F>) -> S, ) -> S
Spawn an instrumented future through a user-supplied spawn function.
spawn_fn must synchronously perform a real Tokio spawn (or an
equivalent operation) before returning; do not defer the future or run
it with block_on. To record the resulting task as instrumented, spawn
on a dial9-traced runtime with task tracking enabled. The closure’s
return value is forwarded back to the caller, so you can keep the
[tokio::task::JoinHandle], [tokio::task::AbortHandle], or whatever
the spawn function returns.
For [tokio::task::JoinSet], prefer
JoinSetExt::spawn_traced.
§Examples
Spawn while retaining the task’s [tokio::task::AbortHandle]:
let handle = Dial9TokioHandle::current();
let abort_handle = handle.spawn_with(work(), |f| tokio::spawn(f).abort_handle());The recorded spawn location is the spawn_fn call site under
--cfg tokio_unstable, and this method’s call site without it. An
inline closure like the one above puts both at the same line.
Trait Implementations§
§impl Clone for Dial9TokioHandle
impl Clone for Dial9TokioHandle
§fn clone(&self) -> Dial9TokioHandle
fn clone(&self) -> Dial9TokioHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Dial9TokioHandle
impl RefUnwindSafe for Dial9TokioHandle
impl Send for Dial9TokioHandle
impl Sync for Dial9TokioHandle
impl Unpin for Dial9TokioHandle
impl UnsafeUnpin for Dial9TokioHandle
impl UnwindSafe for Dial9TokioHandle
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more