pub fn bind_task_hub<F: Future>(fut: F) -> impl Future<Output = F::Output>Expand description
Run a future with its own Sentry Hub so its breadcrumbs never interleave with concurrent tasks. Near-free when no Sentry client is configured.
Forks from Hub::current(), not Hub::main(): the fork inherits the calling
scope, so the caller’s transaction stays the parent of everything inside (a
main() fork has no current span and re-roots inner spans as their own
transactions).
A hub is a snapshot: a thread’s hub is forked off the process hub the first
time that thread touches it, so a client bound afterwards never reaches it,
and captures on a client-less hub are dropped in silence. The fork therefore
re-reads the process hub on every poll and rebinds whenever the client there
is not the one it last took. That tracks the whole enable / disable /
enable cycle a host can drive over FFI: the second enable installs a
different client, and a task that had latched onto the first would keep
reporting into a closed one for the rest of its (long) life.