Effect<Readonly<Record<string, unknown>>, never, never>Returns the tracing span annotations currently carried in the effect context.
Details
These annotations are applied to spans created inside the context, such as
spans created by withSpan, useSpan, or makeSpan.
Example (Providing span annotations)
import { Effect } from "effect"
const program = Effect.gen(function*() {
// Add some annotations to the current span
yield* Effect.annotateCurrentSpan("userId", "123")
yield* Effect.annotateCurrentSpan("operation", "data-processing")
// Retrieve all annotations
const annotations = yield* Effect.spanAnnotations
console.log("Current span annotations:", annotations)
return annotations
})
Effect.runPromise(program).then(console.log)
// Output: Current span annotations: { userId: "123", operation: "data-processing" }export const const spanAnnotations: Effect<
Readonly<Record<string, unknown>>
>
const spanAnnotations: {
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;
}
Returns the tracing span annotations currently carried in the effect context.
Details
These annotations are applied to spans created inside the context, such as
spans created by withSpan, useSpan, or makeSpan.
Example (Providing span annotations)
import { Effect } from "effect"
const program = Effect.gen(function*() {
// Add some annotations to the current span
yield* Effect.annotateCurrentSpan("userId", "123")
yield* Effect.annotateCurrentSpan("operation", "data-processing")
// Retrieve all annotations
const annotations = yield* Effect.spanAnnotations
console.log("Current span annotations:", annotations)
return annotations
})
Effect.runPromise(program).then(console.log)
// Output: Current span annotations: { userId: "123", operation: "data-processing" }
spanAnnotations: 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<type Readonly<T> = {
readonly [P in keyof T]: T[P]
}
Make all properties in T readonly
Readonly<type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<string, unknown>>> = import internalinternal.const spanAnnotations: Effect.Effect<
Readonly<Record<string, unknown>>
>
const spanAnnotations: {
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;
}
spanAnnotations