/** * Lightweight OTel-compatible tracing for Zeta crawler. * * Emits spans as structured JSON logs compatible with OpenTelemetry format. * Drop-in upgrade path: replace this module with @opentelemetry/sdk-node when needed. * * Usage: * const span = startSpan('crawl.url', { url, engine }); * // ... do work ... * endSpan(span, { screensFound: 3 }); */ export interface Span { traceId: string; spanId: string; parentSpanId?: string; name: string; startTimeMs: number; attributes: Record; } export interface FinishedSpan extends Span { endTimeMs: number; durationMs: number; status: 'ok' | 'error'; error?: string; } /** Start a new span. If a trace is already active, the new span is a child. */ export declare function startSpan(name: string, attributes?: Record): Span; /** End a span and emit it as a structured log line. */ export declare function endSpan(span: Span, extraAttributes?: Record, error?: Error): FinishedSpan; /** Convenience: wrap an async function in a span. */ export declare function withSpan(name: string, attributes: Record, fn: (span: Span) => Promise): Promise; export declare function increment(metric: string, value?: number, tags?: Record): void; /** Flush counters as a structured log — call periodically (e.g. at job end). */ export declare function flushMetrics(): Record;