/** * @name observability/metrics * @description Process-local Prometheus metrics for SAP MCP Server. * * The exporter is opt-in and VPS-only: it starts only when `enableMetrics` is * true in the server config (default false). On local user deployments metrics * stay disabled, preserving the current optional behavior. Tool-call counters * are incremented from the central `tools/call` handler in `sdk-compat.ts` * regardless of whether the HTTP exporter is running, but the recording is a * no-op until `initMetrics` is called, so there is zero overhead when disabled. * * Metrics exposed on the `/metrics` endpoint (Prometheus text format): * - sap_mcp_tool_calls_total{tool,status} counter * - sap_mcp_tool_call_duration_seconds{tool} histogram (bucketed) * - sap_mcp_tool_calls_in_flight gauge * - sap_mcp_requests_total{endpoint,status} counter * - sap_mcp_uptime_seconds gauge * * @module observability/metrics */ /** * @name initMetrics * @description Enables metric collection. Safe to call multiple times; the first * call records the baseline start time. */ export declare function initMetrics(): void; /** * @name isMetricsEnabled * @description Reports whether metric collection is active. */ export declare function isMetricsEnabled(): boolean; /** * @name recordToolCall * @description Records a completed tool invocation. No-op when metrics are disabled. * * @param tool — Canonical tool name. * @param durationMs — Call duration in milliseconds. * @param ok — Whether the call returned without throwing. */ export declare function recordToolCall(tool: string, durationMs: number, ok: boolean): void; /** * @name recordRequest * @description Records an inbound HTTP request (MCP endpoint, landing, well-known). * * @param endpoint — Logical endpoint label. * @param status — HTTP status class (`ok` | `error`). */ export declare function recordRequest(endpoint: string, status: 'ok' | 'error'): void; /** * @name trackInFlight * @description Increments the in-flight gauge on call start and decrements on finish. */ export declare function trackInFlight(delta: number): void; /** * @name renderMetrics * @description Serializes the current metric state in Prometheus text exposition format. */ export declare function renderMetrics(): string; /** * @name startMetricsExporter * @description Starts the Prometheus `/metrics` HTTP exporter on the given port. * * The exporter is independent of the MCP HTTP server so it can bind a dedicated * scrape port (default 9090) without affecting the MCP endpoint. Returns the * created HTTP server, or `null` when metrics are disabled. * * @param port — TCP port for the `/metrics` endpoint. */ export declare function startMetricsExporter(port: number): import('http').Server | null; /** * @name stopMetricsExporter * @description Stops a previously started metrics exporter server. */ export declare function stopMetricsExporter(server: import('http').Server | null): void; //# sourceMappingURL=metrics.d.ts.map