Hyperlinkv0.8.0-beta.28

Effect

Effect.withSpanScopedconsteffect/Effect.ts:8378
(name: string, options?: SpanOptions): <A, E, R>(
  self: Effect<A, E, R>
) => Effect<A, E, Exclude<R, ParentSpan> | Scope>
<A, E, R>(
  self: Effect<A, E, R>,
  name: string,
  options?: SpanOptions
): Effect<A, E, Exclude<R, ParentSpan> | Scope>

Wraps the effect with a scoped child span for tracing.

Details

The span is ended when the Scope is finalized.

Example (Creating a scoped child span)

import { Effect } from "effect"

const program = Effect.scoped(
  Effect.gen(function*() {
    const task = Effect.log("Working...")
    yield* Effect.withSpanScoped(task, "scoped-task")
    return "completed"
  })
)
tracing
Source effect/Effect.ts:837813 lines
export const withSpanScoped: {
  (
    name: string,
    options?: SpanOptions
  ): <A, E, R>(
    self: Effect<A, E, R>
  ) => Effect<A, E, Exclude<R, ParentSpan> | Scope>
  <A, E, R>(
    self: Effect<A, E, R>,
    name: string,
    options?: SpanOptions
  ): Effect<A, E, Exclude<R, ParentSpan> | Scope>
} = internal.withSpanScoped