Hyperlinkv0.8.0-beta.28

Effect

Effect.withSpanconsteffect/Effect.ts:8338
<Args extends ReadonlyArray<any>>(
  name: string,
  options?:
    | SpanOptionsNoTrace
    | ((...args: NoInfer<Args>) => SpanOptionsNoTrace)
    | undefined,
  traceOptions?: TraceOptions | undefined
): <A, E, R>(
  self: Effect<A, E, R>,
  ...args: Args
) => Effect<A, E, Exclude<R, ParentSpan>>
<A, E, R>(
  self: Effect<A, E, R>,
  name: string,
  options?: SpanOptions | undefined
): Effect<A, E, Exclude<R, ParentSpan>>

Wraps the effect with a child span for tracing.

Example (Wrapping an effect in a child span)

import { Effect } from "effect"

const task = Effect.gen(function*() {
  yield* Effect.log("Executing task")
  return "result"
})

const traced = Effect.withSpan(task, "my-task", {
  attributes: { version: "1.0" }
})
tracing
Source effect/Effect.ts:833815 lines
export const withSpan: {
  <Args extends ReadonlyArray<any>>(
    name: string,
    options?:
      | SpanOptionsNoTrace
      | ((...args: NoInfer<Args>) => SpanOptionsNoTrace)
      | undefined,
    traceOptions?: TraceOptions | undefined
  ): <A, E, R>(self: Effect<A, E, R>, ...args: Args) => Effect<A, E, Exclude<R, ParentSpan>>
  <A, E, R>(
    self: Effect<A, E, R>,
    name: string,
    options?: SpanOptions | undefined
  ): Effect<A, E, Exclude<R, ParentSpan>>
} = internal.withSpan
Referenced by 1 symbols