Hyperlinkv0.8.0-beta.28

Effect

Effect.currentSpanconsteffect/Effect.ts:8066
Effect<Span, Cause.NoSuchElementError, never>

Returns the currently active local tracing span.

Details

The effect fails with NoSuchElementError when there is no active local Span.

Example (Reading the current span)

import { Effect } from "effect"

const program = Effect.gen(function*() {
  const span = yield* Effect.currentSpan
  yield* Effect.log(`Current span: ${span}`)
  return "done"
})

const traced = Effect.withSpan(program, "my-span")
tracing
Source effect/Effect.ts:80661 lines
export const currentSpan: Effect<Span, Cause.NoSuchElementError> = internal.currentSpan