/** * OBSERVABILITY - Distributed tracing, metrics, structured logging * OpenTelemetry integration, Prometheus metrics, performance monitoring */ export declare enum MetricType { COUNTER = "counter", GAUGE = "gauge", HISTOGRAM = "histogram", SUMMARY = "summary" } export declare enum LogLevel { DEBUG = "debug", INFO = "info", WARN = "warn", ERROR = "error", FATAL = "fatal" } export interface TraceContext { trace_id: string; span_id: string; parent_span_id?: string; trace_flags?: number; trace_state?: string; } export interface Span { span_id: string; trace_id: string; parent_span_id?: string; name: string; start_time: Date; end_time?: Date; duration_ms?: number; status: 'success' | 'error' | 'pending'; attributes: Record; events: SpanEvent[]; error?: Error; } export interface SpanEvent { name: string; timestamp: Date; attributes?: Record; } export interface Metric { name: string; type: MetricType; value: number; timestamp: Date; labels: Record; unit?: string; } export interface LogEntry { timestamp: Date; level: LogLevel; message: string; trace_id?: string; span_id?: string; attributes?: Record; error?: Error; stack_trace?: string; } export interface ObservabilityConfig { tracing_enabled?: boolean; metrics_enabled?: boolean; logging_enabled?: boolean; service_name: string; service_version?: string; environment?: string; sampling_rate?: number; export_interval_ms?: number; exporters?: ExporterConfig[]; } export interface ExporterConfig { type: 'console' | 'otlp' | 'jaeger' | 'prometheus' | 'datadog' | 'custom'; endpoint?: string; headers?: Record; protocol?: 'grpc' | 'http'; } export declare class Tracer { private config; private active_spans; private completed_spans; private current_trace_id?; constructor(config: ObservabilityConfig); /** * Start a new span */ startSpan(name: string, attributes?: Record): Span; /** * End a span */ endSpan(span: Span, error?: Error): void; /** * Add event to span */ addSpanEvent(span: Span, name: string, attributes?: Record): void; /** * Set span attribute */ setSpanAttribute(span: Span, key: string, value: unknown): void; /** * Get current trace context */ getCurrentContext(): TraceContext | null; /** * Get all completed spans */ getCompletedSpans(): Span[]; /** * Clear completed spans */ clearSpans(): void; private createNoopSpan; private exportSpan; private generateId; } export declare class MetricsCollector { private config; private metrics; private counters; private gauges; constructor(config: ObservabilityConfig); /** * Increment a counter */ incrementCounter(name: string, value?: number, labels?: Record): void; /** * Set a gauge value */ setGauge(name: string, value: number, labels?: Record): void; /** * Record a histogram value */ recordHistogram(name: string, value: number, labels?: Record, unit?: string): void; /** * Get all metrics */ getMetrics(): Metric[]; /** * Get metrics by name */ getMetricsByName(name: string): Metric[]; /** * Export metrics in Prometheus format */ exportPrometheus(): string; /** * Clear all metrics */ clear(): void; private recordMetric; private getMetricKey; private parseMetricKey; private formatLabels; } export declare class StructuredLogger { private config; private logs; private min_level; constructor(config: ObservabilityConfig, min_level?: LogLevel); /** * Log debug message */ debug(message: string, attributes?: Record): void; /** * Log info message */ info(message: string, attributes?: Record): void; /** * Log warning message */ warn(message: string, attributes?: Record): void; /** * Log error message */ error(message: string, error?: Error, attributes?: Record): void; /** * Log fatal message */ fatal(message: string, error?: Error, attributes?: Record): void; /** * Get all logs */ getLogs(level?: LogLevel): LogEntry[]; /** * Clear logs */ clear(): void; /** * Export logs as JSON */ exportJSON(): string; private log; private shouldLog; private consoleOutput; } export declare class ObservabilityManager { private config; tracer: Tracer; metrics: MetricsCollector; logger: StructuredLogger; constructor(config: ObservabilityConfig); /** * Trace an async operation */ traceAsync(name: string, operation: (span: Span) => Promise, attributes?: Record): Promise; /** * Trace a synchronous operation */ traceSync(name: string, operation: (span: Span) => T, attributes?: Record): T; /** * Time an operation and record metric */ timeAsync(metric_name: string, operation: () => Promise, labels?: Record): Promise; /** * Get health status */ getHealth(): { status: 'healthy' | 'degraded' | 'unhealthy'; tracing_enabled: boolean; metrics_enabled: boolean; logging_enabled: boolean; active_spans: number; total_metrics: number; total_logs: number; }; } //# sourceMappingURL=observability.d.ts.map