Hyperlinkv0.8.0-beta.28

Effect

Effect.currentParentSpanconsteffect/Effect.ts:8099
Effect<AnySpan, Cause.NoSuchElementError, never>

Returns the current parent span from the effect context.

Details

The effect succeeds with either a local span or external span when one is present, and fails with NoSuchElementError when no parent span is available.

Example (Reading the parent span)

import { Effect } from "effect"

const childOperation = Effect.gen(function*() {
  const parentSpan = yield* Effect.currentParentSpan
  yield* Effect.log(`Parent span: ${parentSpan}`)
  return "child completed"
})

const program = Effect.gen(function*() {
  yield* Effect.withSpan(childOperation, "child-span")
  return "parent completed"
})

const traced = Effect.withSpan(program, "parent-span")
tracing
Source effect/Effect.ts:80991 lines
export const currentParentSpan: Effect<AnySpan, Cause.NoSuchElementError> = internal.currentParentSpan