/** * Comprehensive Telemetry and Observability Types * OpenTelemetry-compatible tracing, metrics, and logging */ import { ModelProvider } from './vendors'; export interface Span { trace_id: string; span_id: string; parent_span_id?: string; name: string; kind: SpanKind; start_time: number; end_time?: number; attributes: SpanAttributes; events: SpanEvent[]; links: SpanLink[]; status: SpanStatus; resource: Resource; } export declare enum SpanKind { INTERNAL = "INTERNAL", SERVER = "SERVER", CLIENT = "CLIENT", PRODUCER = "PRODUCER", CONSUMER = "CONSUMER" } export interface SpanAttributes { 'service.name': string; 'service.version': string; 'http.method'?: string; 'http.url'?: string; 'http.status_code'?: number; 'http.target'?: string; 'llm.provider'?: ModelProvider; 'llm.model'?: string; 'llm.request.type'?: 'chat' | 'completion' | 'embedding' | 'function_call'; 'llm.request.id'?: string; 'llm.prompt.tokens'?: number; 'llm.completion.tokens'?: number; 'llm.total.tokens'?: number; 'llm.temperature'?: number; 'llm.max_tokens'?: number; 'llm.streaming'?: boolean; 'orchestration.routing_strategy'?: string; 'orchestration.connector_id'?: string; 'orchestration.experiment_id'?: string; 'orchestration.variant_id'?: string; 'orchestration.fallback_count'?: number; 'orchestration.retry_count'?: number; 'cost.amount'?: number; 'cost.currency'?: string; [key: string]: string | number | boolean | undefined; } export interface SpanEvent { name: string; timestamp: number; attributes?: Record; } export interface SpanLink { trace_id: string; span_id: string; attributes?: Record; } export interface SpanStatus { code: SpanStatusCode; message?: string; } export declare enum SpanStatusCode { UNSET = "UNSET", OK = "OK", ERROR = "ERROR" } export interface Resource { attributes: ResourceAttributes; } export interface ResourceAttributes { 'service.name': string; 'service.version': string; 'service.instance.id': string; 'deployment.environment': string; 'host.name'?: string; 'host.type'?: string; 'cloud.provider'?: string; 'cloud.region'?: string; 'cloud.availability_zone'?: string; [key: string]: string | undefined; } export interface Trace { trace_id: string; spans: Span[]; root_span: Span; duration_ms: number; start_time: Date; end_time: Date; status: SpanStatusCode; metadata?: Record; } export interface Metric { name: string; type: MetricType; value: number; timestamp: Date; labels: MetricLabels; unit?: string; } export declare enum MetricType { COUNTER = "counter", GAUGE = "gauge", HISTOGRAM = "histogram", SUMMARY = "summary" } export interface MetricLabels { project_id?: string; provider?: ModelProvider; model?: string; connector_id?: string; routing_strategy?: string; status?: string; error_type?: string; user_id?: string; [key: string]: string | undefined; } export interface Counter extends Metric { type: MetricType.COUNTER; value: number; } export interface Gauge extends Metric { type: MetricType.GAUGE; value: number; } export interface Histogram extends Metric { type: MetricType.HISTOGRAM; buckets: HistogramBucket[]; count: number; sum: number; } export interface HistogramBucket { upper_bound: number; count: number; } export interface Summary extends Metric { type: MetricType.SUMMARY; quantiles: SummaryQuantile[]; count: number; sum: number; } export interface SummaryQuantile { quantile: number; value: number; } export declare enum SDKMetric { REQUESTS_TOTAL = "model_orch_requests_total", REQUESTS_ACTIVE = "model_orch_requests_active", REQUESTS_DURATION_SECONDS = "model_orch_requests_duration_seconds", TOKENS_TOTAL = "model_orch_tokens_total", TOKENS_INPUT = "model_orch_tokens_input", TOKENS_OUTPUT = "model_orch_tokens_output", COST_TOTAL = "model_orch_cost_total", COST_PER_REQUEST = "model_orch_cost_per_request", ERRORS_TOTAL = "model_orch_errors_total", ERRORS_RATE = "model_orch_errors_rate", MODEL_LATENCY_SECONDS = "model_orch_model_latency_seconds", MODEL_AVAILABILITY = "model_orch_model_availability", CIRCUIT_BREAKER_STATE = "model_orch_circuit_breaker_state", CIRCUIT_BREAKER_FAILURES = "model_orch_circuit_breaker_failures", RATE_LIMIT_EXCEEDED = "model_orch_rate_limit_exceeded", RATE_LIMIT_REMAINING = "model_orch_rate_limit_remaining", CACHE_HITS = "model_orch_cache_hits", CACHE_MISSES = "model_orch_cache_misses", CACHE_HIT_RATE = "model_orch_cache_hit_rate", ROUTING_DECISIONS = "model_orch_routing_decisions", FALLBACK_TRIGGERED = "model_orch_fallback_triggered", ENSEMBLE_RESPONSES = "model_orch_ensemble_responses", ENSEMBLE_AGGREGATION_DURATION_SECONDS = "model_orch_ensemble_aggregation_duration_seconds" } export interface LogEntry { timestamp: Date; level: LogLevel; message: string; context: LogContext; error?: ErrorInfo; trace_id?: string; span_id?: string; } export declare enum LogLevel { TRACE = "TRACE", DEBUG = "DEBUG", INFO = "INFO", WARN = "WARN", ERROR = "ERROR", FATAL = "FATAL" } export interface LogContext { project_id?: string; request_id?: string; user_id?: string; connector_id?: string; provider?: ModelProvider; model?: string; component?: string; [key: string]: string | number | boolean | undefined; } export interface ErrorInfo { name: string; message: string; stack?: string; code?: string; details?: Record; } export interface HealthCheck { status: HealthStatus; timestamp: Date; version: string; checks: ComponentHealth[]; uptime_seconds: number; } export declare enum HealthStatus { HEALTHY = "healthy", DEGRADED = "degraded", UNHEALTHY = "unhealthy" } export interface ComponentHealth { component: string; status: HealthStatus; latency_ms?: number; error?: string; metadata?: Record; } export interface PerformanceMetrics { request_id: string; project_id: string; timestamp: Date; total_duration_ms: number; routing_duration_ms: number; model_call_duration_ms: number; preprocessing_duration_ms: number; postprocessing_duration_ms: number; aggregation_duration_ms?: number; memory_used_mb?: number; cpu_usage_percentage?: number; request_size_bytes: number; response_size_bytes: number; network_latency_ms?: number; time_to_first_token_ms?: number; tokens_per_second?: number; confidence_score?: number; quality_score?: number; } export interface Alert { id: string; name: string; severity: AlertSeverity; status: AlertStatus; condition: AlertCondition; triggered_at: Date; resolved_at?: Date; notification_channels: string[]; metadata: AlertMetadata; } export declare enum AlertSeverity { INFO = "info", WARNING = "warning", ERROR = "error", CRITICAL = "critical" } export declare enum AlertStatus { ACTIVE = "active", ACKNOWLEDGED = "acknowledged", RESOLVED = "resolved", SILENCED = "silenced" } export interface AlertCondition { metric: string; operator: AlertOperator; threshold: number; window_seconds: number; evaluation_frequency_seconds: number; } export declare enum AlertOperator { GREATER_THAN = "gt", LESS_THAN = "lt", EQUALS = "eq", NOT_EQUALS = "ne" } export interface AlertMetadata { project_id?: string; connector_id?: string; provider?: ModelProvider; model?: string; current_value?: number; threshold_value?: number; description?: string; runbook_url?: string; [key: string]: string | number | undefined; } export interface TraceContext { trace_id: string; span_id: string; trace_flags: number; trace_state?: string; } export interface PropagatedContext { traceparent: string; tracestate?: string; baggage?: Record; } export interface ServiceLevelIndicator { name: string; type: SLIType; current_value: number; target_value: number; unit: string; measurement_window: MeasurementWindow; status: SLIStatus; } export declare enum SLIType { AVAILABILITY = "availability", LATENCY = "latency", ERROR_RATE = "error_rate", THROUGHPUT = "throughput", QUALITY = "quality" } export declare enum SLIStatus { MEETING = "meeting", AT_RISK = "at_risk", BREACHED = "breached" } export interface MeasurementWindow { start: Date; end: Date; duration_seconds: number; } export interface ServiceLevelObjective { id: string; name: string; description: string; sli: ServiceLevelIndicator; target_percentage: number; period_days: number; error_budget: ErrorBudget; alerts: SLOAlert[]; } export interface ErrorBudget { total_budget: number; consumed_budget: number; remaining_budget: number; percentage_remaining: number; projected_exhaustion_date?: Date; } export interface SLOAlert { threshold_percentage: number; notification_channels: string[]; triggered: boolean; } export interface Dashboard { id: string; name: string; description?: string; widgets: DashboardWidget[]; layout: DashboardLayout; refresh_interval_seconds: number; time_range: TimeRange; filters?: DashboardFilter[]; } export interface DashboardWidget { id: string; type: WidgetType; title: string; position: WidgetPosition; config: WidgetConfig; } export declare enum WidgetType { LINE_CHART = "line_chart", BAR_CHART = "bar_chart", PIE_CHART = "pie_chart", GAUGE = "gauge", STAT = "stat", TABLE = "table", HEATMAP = "heatmap", LOG_VIEWER = "log_viewer" } export interface WidgetPosition { x: number; y: number; width: number; height: number; } export type WidgetConfig = ChartWidgetConfig | GaugeWidgetConfig | StatWidgetConfig | TableWidgetConfig | LogViewerConfig; export interface ChartWidgetConfig { metrics: string[]; aggregation: 'sum' | 'avg' | 'min' | 'max' | 'count'; group_by?: string[]; filters?: Record; } export interface GaugeWidgetConfig { metric: string; min: number; max: number; thresholds: Array<{ value: number; color: string; }>; } export interface StatWidgetConfig { metric: string; aggregation: 'sum' | 'avg' | 'min' | 'max' | 'count'; format: 'number' | 'percentage' | 'currency' | 'duration'; show_trend: boolean; } export interface TableWidgetConfig { columns: string[]; data_source: string; sort_by?: string; sort_order?: 'asc' | 'desc'; page_size?: number; } export interface LogViewerConfig { log_level_filter?: LogLevel[]; search_query?: string; max_lines: number; tail: boolean; } export declare enum DashboardLayout { GRID = "grid", FLOW = "flow", CUSTOM = "custom" } export interface TimeRange { type: 'relative' | 'absolute'; config: RelativeTimeRange | AbsoluteTimeRange; } export interface RelativeTimeRange { type: 'relative'; duration_seconds: number; } export interface AbsoluteTimeRange { type: 'absolute'; start: Date; end: Date; } export interface DashboardFilter { field: string; operator: 'eq' | 'ne' | 'in' | 'contains'; value: string | string[]; } export interface AuditLogEntry { id: string; timestamp: Date; actor: Actor; action: AuditAction; resource: Resource; changes?: ChangeSet[]; result: AuditResult; metadata?: Record; } export interface Actor { type: 'user' | 'service_account' | 'system'; id: string; name?: string; ip_address?: string; } export declare enum AuditAction { CREATE = "create", READ = "read", UPDATE = "update", DELETE = "delete", EXECUTE = "execute", LOGIN = "login", LOGOUT = "logout" } export interface ChangeSet { field: string; old_value?: unknown; new_value?: unknown; } export declare enum AuditResult { SUCCESS = "success", FAILURE = "failure", PARTIAL = "partial" } //# sourceMappingURL=telemetry.d.ts.map