effect-io-ai

Package: effect
Module: Effect

Effect.makeSpanScoped

Create a new span for tracing, and automatically close it when the Scope finalizes.

Details

The span is not added to the current span stack, so no child spans will be created for it.

Example (Creating a scoped standalone span)

import { Effect } from "effect"

const program = Effect.scoped(
  Effect.gen(function*() {
    const span = yield* Effect.makeSpanScoped("scoped-operation")
    yield* Effect.log("Working...")
    return "done"
    // Span automatically closes when scope ends
  })
)

Signature

declare const makeSpanScoped: (name: string, options?: SpanOptionsNoTrace | undefined) => Effect<Span, never, Scope>

Source

Since v2.0.0