runDetached<R> static method

R runDetached<R>(
  1. R body()
)

Runs body with no current span, whatever the surrounding zone has.

For work that outlives the request that started it. A zone value is inherited by anything spawned inside it, so a background task would otherwise keep writing to a span that has already ended and already been exported — attributes belonging to work the trace never covered, and a race on the span's own map if two tasks do it at once.

Implementation

static R runDetached<R>(R Function() body) =>
    runZoned(body, zoneValues: {_zoneKey: null});