import { LogError, type LogEvent } from "./conform.ts"; import type { Spec } from "../spec/index.ts"; /** A span, as every trace format has it, with its attributes flattened to plain values. */ export interface TraceSpan { traceId: string; spanId: string; parentSpanId?: string; /** Spans it is linked to, as a consumer's span to its producer's. */ links: { traceId: string; spanId: string; }[]; name: string; kind: "internal" | "server" | "client" | "producer" | "consumer" | "unspecified"; /** Nanoseconds since the epoch. */ start: bigint; end: bigint; attributes: Record; /** The resource's attributes: the service that made the span. */ resource: Record; } /** * What a span means for the spec, for spans that do not say themselves: a log line, as JSON * Lines has it (`{instance, key, inputs, payload, …}`, and `actor` for an instance to spawn), * or undefined to skip it. What it leaves out comes from the span: the instance from its * service, and the sender from its parents. */ export type TraceMapping = (span: TraceSpan) => Record | undefined; export type TraceFormat = "otlp" | "jaeger" | "zipkin"; /** Which trace format a text is in, if it is one: undefined for a JSON Lines log. */ export declare function traceFormat(text: string): TraceFormat | undefined; /** Every span in a trace file, whichever format it is in. */ export declare function readSpans(text: string, format?: TraceFormat): TraceSpan[]; export interface TraceLogOptions { /** For spans without `feynman.step`: what each means, or undefined to skip it. */ map?: TraceMapping; /** Only the spans of this trace. */ traceId?: string; /** Causal, by default: each instance's order, and causes before effects. Time: by the clocks. */ order?: "causal" | "time"; } /** A trace's steps, as the log events `conform` follows: spawns first, then steps in order. */ export declare function traceLog(spans: TraceSpan[], spec: Spec, options?: TraceLogOptions): LogEvent[]; /** A span as a person finds it in their tracing UI: its name, service and id. */ export declare function where(span: TraceSpan): string; export declare class TraceError extends LogError { constructor(what: string); }