/** * @since 2.0.0 */ import type * as Context from "./Context.js" import type * as Effect from "./Effect.js" import type * as Exit from "./Exit.js" import type * as Fiber from "./Fiber.js" import type { LazyArg } from "./Function.js" import * as defaultServices from "./internal/defaultServices.js" import * as internal from "./internal/tracer.js" import type * as Option from "./Option.js" /** * @since 2.0.0 */ export const TracerTypeId: unique symbol = internal.TracerTypeId /** * @since 2.0.0 */ export type TracerTypeId = typeof TracerTypeId /** * @since 2.0.0 */ export interface Tracer { readonly [TracerTypeId]: TracerTypeId span( name: string, parent: Option.Option, context: Context.Context, links: ReadonlyArray, startTime: bigint, kind: SpanKind, options?: SpanOptions ): Span context(f: () => X, fiber: Fiber.RuntimeFiber): X } /** * @since 2.0.0 * @category models */ export type SpanStatus = { _tag: "Started" startTime: bigint } | { _tag: "Ended" startTime: bigint endTime: bigint exit: Exit.Exit } /** * @since 2.0.0 * @category models */ export type AnySpan = Span | ExternalSpan /** * @since 2.0.0 * @category tags */ export interface ParentSpan { readonly _: unique symbol } /** * @since 2.0.0 * @category tags */ export const ParentSpan: Context.Tag = internal.spanTag /** * @since 2.0.0 * @category models */ export interface ExternalSpan { readonly _tag: "ExternalSpan" readonly spanId: string readonly traceId: string readonly sampled: boolean readonly context: Context.Context } /** * @since 3.1.0 * @category models */ export interface SpanOptions { readonly attributes?: Record | undefined readonly links?: ReadonlyArray | undefined readonly parent?: AnySpan | undefined readonly root?: boolean | undefined readonly context?: Context.Context | undefined readonly kind?: SpanKind | undefined readonly captureStackTrace?: boolean | LazyArg | undefined } /** * @since 3.1.0 * @category models */ export type SpanKind = "internal" | "server" | "client" | "producer" | "consumer" /** * @since 2.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 sampled: boolean readonly kind: SpanKind end(endTime: bigint, exit: Exit.Exit): void attribute(key: string, value: unknown): void event(name: string, startTime: bigint, attributes?: Record): void addLinks(links: ReadonlyArray): void } /** * @since 2.0.0 * @category models */ export interface SpanLink { readonly _tag: "SpanLink" readonly span: AnySpan readonly attributes: Readonly> } /** * @since 2.0.0 * @category tags */ export const Tracer: Context.Tag = internal.tracerTag /** * @since 2.0.0 * @category constructors */ export const make: (options: Omit) => Tracer = internal.make /** * @since 2.0.0 * @category constructors */ export const externalSpan: ( options: { readonly spanId: string readonly traceId: string readonly sampled?: boolean | undefined readonly context?: Context.Context | undefined } ) => ExternalSpan = internal.externalSpan /** * @since 2.0.0 * @category constructors */ export const tracerWith: (f: (tracer: Tracer) => Effect.Effect) => Effect.Effect = defaultServices.tracerWith /** * @since 3.12.0 * @category annotations */ export interface DisablePropagation { readonly _: unique symbol } /** * @since 3.12.0 * @category annotations */ export const DisablePropagation: Context.Reference = internal.DisablePropagation