<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" }
})export const 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>>
}
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" }
})
withSpan: {
<function (type parameter) Args in <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>>Args extends interface ReadonlyArray<T>ReadonlyArray<any>>(
name: stringname: string,
options: | SpanOptionsNoTrace
| ((
...args: NoInfer<Args>
) => SpanOptionsNoTrace)
| undefined
options?:
| SpanOptionsNoTrace
| ((...args: NoInfer<Args>args: type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) Args in <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>>Args>) => SpanOptionsNoTrace)
| undefined,
traceOptions: TraceOptions | undefinedtraceOptions?: TraceOptions | undefined
): <function (type parameter) A in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>A, function (type parameter) E in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>E, function (type parameter) R in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>R>(self: Effect<A, E, R>(parameter) self: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>A, function (type parameter) E in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>E, function (type parameter) R in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>R>, ...args: Args extends ReadonlyArray<any>args: function (type parameter) Args in <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>>Args) => interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>A, function (type parameter) E in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>E, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) R in <A, E, R>(self: Effect<A, E, R>, ...args: Args): Effect<A, E, Exclude<R, ParentSpan>>R, class ParentSpanclass ParentSpan {
Service: Service;
key: Identifier;
}
Context service containing the Span or ExternalSpan to use as the parent
of newly-created child spans.
Example (Accessing the parent span)
import { Effect, Tracer } from "effect"
// Access the parent span from the context
const program = Effect.gen(function*() {
const parentSpan = yield* Effect.service(Tracer.ParentSpan)
console.log(`Parent span: ${parentSpan.spanId}`)
})
ParentSpan>>
<function (type parameter) A in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>A, function (type parameter) E in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>E, function (type parameter) R in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>R>(
self: Effect<A, E, R>(parameter) self: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>A, function (type parameter) E in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>E, function (type parameter) R in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>R>,
name: stringname: string,
options: SpanOptions | undefinedoptions?: SpanOptions | undefined
): interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>A, function (type parameter) E in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>E, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) R in <A, E, R>(self: Effect<A, E, R>, name: string, options?: SpanOptions | undefined): Effect<A, E, Exclude<R, ParentSpan>>R, class ParentSpanclass ParentSpan {
Service: Service;
key: Identifier;
}
Context service containing the Span or ExternalSpan to use as the parent
of newly-created child spans.
Example (Accessing the parent span)
import { Effect, Tracer } from "effect"
// Access the parent span from the context
const program = Effect.gen(function*() {
const parentSpan = yield* Effect.service(Tracer.ParentSpan)
console.log(`Parent span: ${parentSpan.spanId}`)
})
ParentSpan>>
} = import internalinternal.const withSpan: {
<Args extends ReadonlyArray<any>>(
name: string,
options?:
| Tracer.SpanOptionsNoTrace
| ((
...args: NoInfer<Args>
) => Tracer.SpanOptionsNoTrace)
| undefined,
traceOptions?: Tracer.TraceOptions | undefined
): <A, E, R>(
self: Effect.Effect<A, E, R>,
...args: Args
) => Effect.Effect<
A,
E,
Exclude<R, Tracer.ParentSpan>
>
<A, E, R>(
self: Effect.Effect<A, E, R>,
name: string,
options?: Tracer.SpanOptions | undefined
): Effect.Effect<
A,
E,
Exclude<R, Tracer.ParentSpan>
>
}
withSpan