import { R as RuntimeHooks, c as RingBufferOptions, d as RuntimeEvent, e as RuntimeEmitContext, f as RuntimeEventRecord, g as RuntimeSpanLink, T as TraceContext, B as Baggage } from './effect-DbEMiMvv.js'; import { R as RuntimeClock } from './layer-CsNGeVee.js'; type MetricType = "counter" | "gauge" | "histogram"; type MetricValue = { readonly name: string; readonly type: MetricType; readonly value: number; readonly labels: Record; readonly timestamp: number; }; type HistogramBuckets = { readonly boundaries: readonly number[]; counts: number[]; sum: number; count: number; min: number; max: number; exemplars?: Array; }; type MetricExemplar = { readonly value: number; readonly timestamp: number; readonly traceId?: string; readonly spanId?: string; readonly labels?: Record; }; type MetricsRegistry = { /** Create or get a counter. */ readonly counter: (name: string, labels?: Record) => Counter; /** Create or get a gauge. */ readonly gauge: (name: string, labels?: Record) => Gauge; /** Create or get a histogram. */ readonly histogram: (name: string, boundaries?: number[], labels?: Record) => Histogram; /** Get all current metric values. */ readonly snapshot: () => MetricSnapshot; /** Reset all metrics. */ readonly reset: () => void; }; type Counter = { readonly increment: (n?: number) => void; readonly value: () => number; }; type Gauge = { readonly set: (value: number) => void; readonly increment: (n?: number) => void; readonly decrement: (n?: number) => void; readonly value: () => number; }; type Histogram = { readonly observe: (value: number, exemplar?: Omit | MetricExemplar) => void; readonly buckets: () => HistogramBuckets; readonly percentile: (p: number) => number; }; type MetricSnapshot = { readonly counters: Array<{ name: string; labels: Record; value: number; }>; readonly gauges: Array<{ name: string; labels: Record; value: number; }>; readonly histograms: Array<{ name: string; labels: Record; buckets: HistogramBuckets; }>; }; /** * Creates a metrics registry. * * ```ts * const metrics = makeMetrics(); * * const requestCount = metrics.counter("http_requests_total", { method: "GET" }); * requestCount.increment(); * * const latency = metrics.histogram("http_request_duration_ms"); * latency.observe(42.5); * * const activeConns = metrics.gauge("active_connections"); * activeConns.set(10); * * console.log(metrics.snapshot()); * ``` */ declare function makeMetrics(): MetricsRegistry; type EventHandler = (ev: RuntimeEventRecord) => void; declare function runtimeHooksToEventHandler(hooks: RuntimeHooks): EventHandler; type EventBusOptions = RingBufferOptions; declare class EventBus implements RuntimeHooks { private readonly options; private seq; private subs; private flushScheduled; private readonly boundFlush; constructor(options?: EventBusOptions); emit(ev: RuntimeEvent, ctx: RuntimeEmitContext): void; subscribe(handler: EventHandler, perSubscriberCapacity?: number): () => void; subscribeHooks(hooks: RuntimeHooks, perSubscriberCapacity?: number): () => void; flush(budget?: number): void; } type RuntimeSpanEvent = { wallTs: number; name: string; attrs?: unknown; }; type RuntimeSpan = { traceId: string; spanId: string; parentSpanId?: string; traceState?: string; name: string; startWallTs: number; endWallTs?: number; attrs: Record; links: RuntimeSpanLink[]; events: RuntimeSpanEvent[]; }; type InMemoryTracerOptions = { readonly sanitizeAttributes?: (attrs: Record) => Record; readonly sanitizeError?: (error: unknown) => unknown; readonly maxFinishedSpans?: number; readonly maxSpanAgeMs?: number; readonly clock?: () => number; }; type InMemoryTracerStats = { readonly storedSpans: number; readonly finishedSpans: number; readonly prunedFinishedSpans: number; }; declare class InMemoryTracer implements RuntimeHooks { private readonly options; spans: Map; private readonly finishedSpanIds; private readonly finishedSpanSet; private finishedSpanOffset; private finishedSpanCount; private prunedFinishedSpans; constructor(options?: InMemoryTracerOptions); emit(ev: RuntimeEvent, ctx: RuntimeEmitContext): void; exportFinished(): RuntimeSpan[]; pruneFinished(spanIds?: Iterable): number; stats(): InMemoryTracerStats; private attrs; private error; private now; private pruneExpiredFinished; private pruneFinishedOverLimit; private markFinished; private deleteFinished; private peekOldestFinished; private deleteOldestFinished; private compactFinishedIds; } type TraceSamplingInput = { readonly traceId: string; readonly spanName?: string; readonly parentSampled?: boolean; readonly attributes?: Record; }; type TraceSampler = ((input: TraceSamplingInput) => boolean) | { shouldSample(input: TraceSamplingInput): boolean; }; interface Tracer { newTraceId(): string; newSpanId(): string; } declare const defaultTracer: Tracer; type BrassEnv = { brass?: { tracer?: Tracer; traceSeed?: TraceContext; baggage?: Baggage; sampler?: TraceSampler; respectRemoteSampled?: boolean; forceSampleOnError?: boolean; childName?: (parentName?: string) => string | undefined; clock?: RuntimeClock; }; }; export { type BrassEnv as B, type Counter as C, EventBus as E, type Gauge as G, type Histogram as H, InMemoryTracer as I, type MetricsRegistry as M, type RuntimeSpan as R, type TraceSampler as T, type MetricExemplar as a, type MetricSnapshot as b, type TraceSamplingInput as c, type Tracer as d, type InMemoryTracerOptions as e, type EventBusOptions as f, type EventHandler as g, type HistogramBuckets as h, type InMemoryTracerStats as i, type MetricType as j, type MetricValue as k, type RuntimeSpanEvent as l, defaultTracer as m, makeMetrics as n, runtimeHooksToEventHandler as r };