<A, E, R>(
name: string,
evaluate: (span: Span) => Effect<A, E, R>
): Effect<A, E, R>
<A, E, R>(
name: string,
options: SpanOptionsNoTrace,
evaluate: (span: Span) => Effect<A, E, R>
): Effect<A, E, R>Create a new span for tracing, and automatically close it when the effect completes.
Details
The span is not added to the current span stack, so no child spans will be created for it.
Example (Running an effect with a standalone span)
import { Effect } from "effect"
const program = Effect.useSpan(
"user-operation",
(span) =>
Effect.gen(function*() {
yield* Effect.log("Processing user data")
return "success"
})
)export const const useSpan: {
<A, E, R>(
name: string,
evaluate: (span: Span) => Effect<A, E, R>
): Effect<A, E, R>
<A, E, R>(
name: string,
options: SpanOptionsNoTrace,
evaluate: (span: Span) => Effect<A, E, R>
): Effect<A, E, R>
}
Create a new span for tracing, and automatically close it when the effect
completes.
Details
The span is not added to the current span stack, so no child spans will be
created for it.
Example (Running an effect with a standalone span)
import { Effect } from "effect"
const program = Effect.useSpan(
"user-operation",
(span) =>
Effect.gen(function*() {
yield* Effect.log("Processing user data")
return "success"
})
)
useSpan: {
<function (type parameter) A in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>A, function (type parameter) E in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>E, function (type parameter) R in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>R>(name: stringname: string, evaluate: (span: Span) => Effect<A, E, R>evaluate: (span: Span(parameter) span: {
_tag: "Span";
name: string;
spanId: string;
traceId: string;
parent: Option.Option<AnySpan>;
annotations: Context.Context<never>;
status: SpanStatus;
attributes: ReadonlyMap<string, unknown>;
links: ReadonlyArray<SpanLink>;
sampled: boolean;
kind: SpanKind;
end: (endTime: bigint, exit: Exit.Exit<unknown, unknown>) => void;
attribute: (key: string, value: unknown) => void;
event: (name: string, startTime: bigint, attributes?: Record<string, unknown>) => void;
addLinks: (links: ReadonlyArray<SpanLink>) => void;
}
span: Span) => 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>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>A, function (type parameter) E in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>E, function (type parameter) R in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>R>): 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>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>A, function (type parameter) E in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>E, function (type parameter) R in <A, E, R>(name: string, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>R>
<function (type parameter) A in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>A, function (type parameter) E in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>E, function (type parameter) R in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>R>(name: stringname: string, options: SpanOptionsNoTrace(parameter) options: {
attributes: Record<string, unknown> | undefined;
links: ReadonlyArray<SpanLink> | undefined;
parent: AnySpan | undefined;
root: boolean | undefined;
annotations: Context.Context<never> | undefined;
kind: SpanKind | undefined;
sampled: boolean | undefined;
level: LogLevel | undefined;
}
options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>evaluate: (span: Span(parameter) span: {
_tag: "Span";
name: string;
spanId: string;
traceId: string;
parent: Option.Option<AnySpan>;
annotations: Context.Context<never>;
status: SpanStatus;
attributes: ReadonlyMap<string, unknown>;
links: ReadonlyArray<SpanLink>;
sampled: boolean;
kind: SpanKind;
end: (endTime: bigint, exit: Exit.Exit<unknown, unknown>) => void;
attribute: (key: string, value: unknown) => void;
event: (name: string, startTime: bigint, attributes?: Record<string, unknown>) => void;
addLinks: (links: ReadonlyArray<SpanLink>) => void;
}
span: Span) => 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>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>A, function (type parameter) E in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>E, function (type parameter) R in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>R>): 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>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>A, function (type parameter) E in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>E, function (type parameter) R in <A, E, R>(name: string, options: SpanOptionsNoTrace, evaluate: (span: Span) => Effect<A, E, R>): Effect<A, E, R>R>
} = import internalinternal.const useSpan: {
<A, E, R>(
name: string,
evaluate: (
span: Tracer.Span
) => Effect.Effect<A, E, R>
): Effect.Effect<A, E, R>
<A, E, R>(
name: string,
options: Tracer.SpanOptionsNoTrace,
evaluate: (
span: Tracer.Span
) => Effect.Effect<A, E, R>
): Effect.Effect<A, E, R>
}
useSpan