UNPKG

@gati-framework/runtime

Version:

Gati runtime execution engine for running handler-based applications

62 lines 2.54 kB
/** * @module runtime/metrics-client * @description Metrics and observability client for Gati runtime */ import * as api from '@opentelemetry/api'; /** * Metrics client interface for runtime components */ export interface MetricsClient { /** Increment a counter metric */ incrementCounter(name: string, labels?: Record<string, string>, value?: number): void; /** Set a gauge metric value */ setGauge(name: string, value: number, labels?: Record<string, string>): void; /** Record a histogram observation */ recordHistogram(name: string, value: number, labels?: Record<string, string>): void; /** Create a new span for tracing */ createSpan(name: string, attributes?: api.Attributes): api.Span; /** Execute function within a span context */ withSpan<T>(name: string, fn: (span: api.Span) => Promise<T>, attributes?: api.Attributes): Promise<T>; /** Log structured message with request context */ logWithContext(level: 'info' | 'warn' | 'error', message: string, context: Record<string, any>): void; /** Record audit event */ recordAudit(event: string, context: AuditContext): void; } /** * Audit context for security logging */ export interface AuditContext { requestId: string; handlerId?: string; version?: string; userId?: string; action: string; resource?: string; result: 'success' | 'failure' | 'denied'; metadata?: Record<string, any>; } /** * Runtime metrics client implementation */ export declare class RuntimeMetricsClient implements MetricsClient { private serviceName; private serviceVersion; private tracer; private metrics?; private counters; private gauges; private histograms; constructor(serviceName?: string, serviceVersion?: string); incrementCounter(name: string, labels?: Record<string, string>, value?: number): void; setGauge(name: string, value: number, labels?: Record<string, string>): void; recordHistogram(name: string, value: number, labels?: Record<string, string>): void; createSpan(name: string, attributes?: api.Attributes): api.Span; withSpan<T>(name: string, fn: (span: api.Span) => Promise<T>, attributes?: api.Attributes): Promise<T>; logWithContext(level: 'info' | 'warn' | 'error', message: string, context: Record<string, any>): void; recordAudit(event: string, context: AuditContext): void; } /** * Default metrics client instance */ export declare const metricsClient: RuntimeMetricsClient; //# sourceMappingURL=metrics-client.d.ts.map