SpanLinkA relationship from one span to another span, with attributes describing the relationship.
Example (Linking spans)
import { Effect, Tracer } from "effect"
// Create a span link to connect spans
const externalSpan = Tracer.externalSpan({
spanId: "external-span-123",
traceId: "trace-456"
})
const link: Tracer.SpanLink = {
span: externalSpan,
attributes: { "link.type": "follows-from", "service": "external-api" }
}
const program = Effect.succeed("result").pipe(
Effect.withSpan("linked-operation", { links: [link] })
)models
Source effect/Tracer.ts:3954 lines
export interface SpanLink {
readonly SpanLink.span: AnySpanspan: type AnySpan = Span | ExternalSpanA span value that can participate in tracing, either an Effect-managed
Span or an ExternalSpan propagated from another tracing system.
Example (Accepting any span)
import { Effect, Tracer } from "effect"
// Function that accepts any span type
const logSpan = (span: Tracer.AnySpan) => {
console.log(`Span ID: ${span.spanId}, Trace ID: ${span.traceId}`)
return Effect.succeed(span)
}
// Works with both Span and ExternalSpan
const externalSpan = Tracer.externalSpan({
spanId: "span-123",
traceId: "trace-456"
})
AnySpan
readonly SpanLink.attributes: Readonly<Record<string, unknown>>attributes: 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>>
}Referenced by 7 symbols