/** * @since 1.0.0 */ import type * as Context from "@effect/data/Context" import type * as Option from "@effect/data/Option" import type * as Effect from "@effect/io/Effect" import type * as Exit from "@effect/io/Exit" import type * as Fiber from "@effect/io/Fiber" import * as defaultServices from "@effect/io/internal/defaultServices" import * as internal from "@effect/io/internal/tracer" /** * @since 1.0.0 */ export const TracerTypeId: unique symbol = internal.TracerTypeId /** * @since 1.0.0 */ export type TracerTypeId = typeof TracerTypeId /** * @since 1.0.0 */ export interface Tracer { readonly [TracerTypeId]: TracerTypeId readonly span: ( name: string, parent: Option.Option, context: Context.Context, links: ReadonlyArray, startTime: bigint ) => Span readonly context: (f: () => X, fiber: Fiber.RuntimeFiber) => X } /** * @since 1.0.0 * @category models */ export type SpanStatus = { _tag: "Started" startTime: bigint } | { _tag: "Ended" startTime: bigint endTime: bigint exit: Exit.Exit } /** * @since 1.0.0 * @category models */ export type ParentSpan = Span | ExternalSpan /** * @since 1.0.0 * @category models */ export interface ExternalSpan { readonly _tag: "ExternalSpan" readonly spanId: string readonly traceId: string readonly context: Context.Context } /** * @since 1.0.0 * @category models */ export interface Span { readonly _tag: "Span" readonly name: string readonly spanId: string readonly traceId: string readonly parent: Option.Option readonly context: Context.Context readonly status: SpanStatus readonly attributes: ReadonlyMap readonly links: ReadonlyArray readonly end: (endTime: bigint, exit: Exit.Exit) => void readonly attribute: (key: string, value: AttributeValue) => void readonly event: (name: string, startTime: bigint, attributes?: Record) => void } /** * @since 1.0.0 * @category models */ export type AttributeValue = string | boolean | number /** * @since 1.0.0 * @category models */ export interface SpanLink { readonly _tag: "SpanLink" readonly span: ParentSpan readonly attributes: Readonly> } /** * @since 1.0.0 * @category tags */ export const Tracer: Context.Tag = internal.tracerTag /** * @since 1.0.0 * @category constructors */ export const make: (options: Omit) => Tracer = internal.make /** * @since 1.0.0 * @category constructors */ export const tracerWith: (f: (tracer: Tracer) => Effect.Effect) => Effect.Effect = defaultServices.tracerWith