UNPKG

@gati-framework/runtime

Version:

Gati runtime execution engine for running handler-based applications

80 lines 2.12 kB
/** * @module runtime/trace-collector * @description Collects request traces through the pipeline */ import type { Request } from './types/request.js'; import type { Response } from './types/response.js'; import type { LocalContext } from './types/context.js'; import type { RequestTrace, StageName } from './types/trace.js'; /** * Trace collector configuration */ export interface TraceCollectorConfig { /** Enable trace collection */ enabled: boolean; /** Maximum traces to keep in memory */ maxTraces: number; /** Trace retention time (ms) */ retentionMs: number; } /** * Collects request traces through pipeline stages */ export declare class TraceCollector { private activeTraces; private config; constructor(config?: Partial<TraceCollectorConfig>); /** * Start collecting a trace for a request */ startTrace(request: Request, traceId: string): void; /** * Capture a pipeline stage */ captureStage(traceId: string, stage: StageName, metadata?: Record<string, unknown>): void; /** * Capture a snapshot at current stage */ captureSnapshot(traceId: string, lctx: LocalContext): void; /** * Complete current stage */ completeStage(traceId: string): void; /** * End trace collection */ endTrace(traceId: string, response?: Response, error?: Error): RequestTrace | null; /** * Get active trace */ getActiveTrace(traceId: string): RequestTrace | null; /** * Enable trace collection */ enable(): void; /** * Disable trace collection */ disable(): void; /** * Check if enabled */ isEnabled(): boolean; /** * Clear all active traces */ clear(): void; /** * Get active trace count */ getActiveCount(): number; /** * Enforce memory limits */ private enforceMemoryLimits; } /** * Create a trace collector instance */ export declare function createTraceCollector(config?: Partial<TraceCollectorConfig>): TraceCollector; //# sourceMappingURL=trace-collector.d.ts.map