/** * RuntimeMeter production wiring for the goodvibes-sdk platform. * * Exposes named metric instruments used across the platform: * - HTTP request counters and histograms * - LLM request counters and histograms * - Auth success/failure counters * - Session and SSE subscriber gauges * - Telemetry buffer fill gauge * * It also holds the process's ACTIVE TRACER, which `telemetry.otelMode` * governs, see {@link platformTracer}. */ import { RuntimeMeter } from './telemetry/meter.js'; import { RuntimeTracer } from './telemetry/tracer.js'; import type { HistogramSnapshot } from './telemetry/types.js'; /** Singleton RuntimeMeter instance for the platform. */ export declare const platformMeter: RuntimeMeter; /** * The tracer the platform's instrumentation opens spans on. * * `telemetry.otelMode` used to be checked in exactly one place, * `createTelemetryProvider`, which had no callers, while the live meter in this * module was built with no reference to it at all. So 'off', 'in-process' and * 'remote-export' produced identical behaviour: no spans, ever, because nothing * held a tracer to open one on. * * This is the seam that closes that. The composed runtime builds a provider from * the mode's two feature gates and installs its tracer here; instrumentation * asks for the tracer per call rather than capturing it, so a host that installs * one after the first LLM request still gets spans from the second. * * A function rather than a mutable export because a `let` binding read through * an ES module namespace is a live view in bundlers and a snapshot in some CJS * interop paths, and "did tracing turn on" is not a question to leave to that. */ export declare function platformTracer(): RuntimeTracer; /** * Install the process's tracer. Called once by the composed runtime. * * Passing `null` restores the recording-nothing tracer, which is what a test * that turned tracing on uses to put the process back. */ export declare function installPlatformTracer(tracer: RuntimeTracer | null): void; /** Counter: total HTTP requests by method and status_class (2xx, 4xx, 5xx). */ export declare const httpRequestsTotal: import("./telemetry/types.js").Counter; /** Histogram: HTTP request latency in ms by method, path_pattern, status_class. */ export declare const httpRequestDurationMs: import("./telemetry/types.js").Histogram; /** Counter: total LLM requests started by provider, model (emitted on entry, before the call). */ export declare const llmRequestsStarted: import("./telemetry/types.js").Counter; /** Counter: total LLM requests by provider, model, status (success/error). */ export declare const llmRequestsTotal: import("./telemetry/types.js").Counter; /** Histogram: LLM request latency in ms by provider, model. */ export declare const llmRequestDurationMs: import("./telemetry/types.js").Histogram; /** Histogram: LLM input token counts by provider, model. */ export declare const llmTokensInput: import("./telemetry/types.js").Histogram; /** Histogram: LLM output token counts by provider, model. */ export declare const llmTokensOutput: import("./telemetry/types.js").Histogram; /** Counter: successful auth events. */ export declare const authSuccessTotal: import("./telemetry/types.js").Counter; /** Counter: failed auth events. */ export declare const authFailureTotal: import("./telemetry/types.js").Counter; /** Gauge: currently active sessions. */ export declare const sessionsActive: import("./telemetry/types.js").Gauge; /** Gauge: current SSE subscriber count per stream type. */ export declare const sseSubscribers: import("./telemetry/types.js").Gauge; /** Counter: total transport retries by transport_type and reason. */ export declare const transportRetriesTotal: import("./telemetry/types.js").Counter; /** Gauge: fill level of the telemetry buffer (0..1). */ export declare const telemetryBufferFill: import("./telemetry/types.js").Gauge; /** Counter: total listener errors caught during event dispatch. */ export declare const listenerErrorsTotal: import("./telemetry/types.js").Counter; /** * Reset all metric instruments on the singleton platform meter. * Use in afterEach() hooks to prevent singleton state from bleeding between tests. */ export declare function resetMetrics(): void; /** A bucketed counter split by an outcome label (e.g. status class, success/error). */ export interface RuntimeMetricsBucket { readonly [label: string]: number; } /** The JSON-serialisable shape `snapshotMetrics()` returns. */ export interface RuntimeMetricsSnapshot { readonly counters: { readonly http: { readonly requests: { readonly total: RuntimeMetricsBucket; }; }; readonly llm: { readonly requests: { readonly total: RuntimeMetricsBucket; }; }; readonly auth: { readonly success: { readonly total: number; }; readonly failure: { readonly total: number; }; }; readonly transport: { readonly retries_total: number; }; readonly [flatKey: string]: unknown; }; readonly gauges: { readonly sessions: { readonly active: number; }; readonly sse: { readonly subscribers: number; }; readonly telemetry: { readonly buffer: { readonly fill: number; }; }; readonly [flatKey: string]: unknown; }; readonly histograms: { readonly 'http.request.duration_ms': HistogramSnapshot; readonly 'llm.request.duration_ms': HistogramSnapshot; readonly 'llm.tokens.input': HistogramSnapshot; readonly 'llm.tokens.output': HistogramSnapshot; }; /** Per-model edit-failure + declared-exec-expectation-miss counts (see tool-format-telemetry.ts). */ readonly toolFormat: { readonly byModel: Record>; readonly byClass: Record; }; readonly [topLevelKey: string]: unknown; } /** * Snapshot all metric instruments as a JSON-serialisable object. * * Reachable two ways: the `runtime.metrics.get` operator method (typed IO, * catalog-registered, see method-catalog-runtime.ts and routes/runtime- * metrics.ts), and its REST binding `GET /api/runtime/metrics`. Consumers * needing this shape directly (not through the operator client) can import * `snapshotMetrics`/`RuntimeMetricsSnapshot` from * `@pellux/goodvibes-sdk/platform/runtime/observability`. */ export declare function snapshotMetrics(): RuntimeMetricsSnapshot; //# sourceMappingURL=metrics.d.ts.map