/** * OpenTelemetry GenAI Metrics for Photon * * Zero-dependency metrics wrappers that no-op when @opentelemetry/api is not * installed. Mirrors the pattern in otel.ts for traces. * * Metric names follow OTel GenAI semantic conventions where applicable and * `photon.*` for runtime-specific instruments. */ export interface PhotonCounter { add(value: number, attributes?: Record): void; } export interface PhotonHistogram { record(value: number, attributes?: Record): void; } /** * Record a tool-call completion. Emits to both a latency histogram and a call * counter so operators can derive rate, error rate, and p95/p99 from one pair. */ export declare function recordToolCall(params: { photon: string; tool: string; durationMs: number; status: 'ok' | 'error'; errorType?: string; stateful?: boolean; }): void; /** * Record a rate-limit rejection. Incremented every time a `@throttled` * or `@rateLimit` middleware throws `PhotonRateLimitError`. */ export declare function recordRateLimitRejection(params: { photon: string; tool: string; instance?: string; }): void; /** * Record a bulkhead rejection. Incremented every time the @bulkhead * middleware throws PhotonBulkheadFullError because concurrent-execution * cap was reached. */ export declare function recordBulkheadRejection(params: { photon: string; tool: string; instance?: string; }): void; /** * Record a circuit-breaker state transition. * Attributes capture the photon/tool key and the new state so dashboards can * alert on "open" without sampling the call stream. */ export declare function recordCircuitStateChange(params: { photon: string; tool: string; instance?: string; from: 'closed' | 'open' | 'half-open'; to: 'closed' | 'open' | 'half-open'; }): void; /** * Record an OAuth authorization-server event. One counter per endpoint + * status so operators can alert on error rates and track CIMD vs DCR * adoption without sampling logs. */ export declare function recordAuthEvent(params: { /** Which AS endpoint. */ endpoint: 'authorize' | 'token' | 'register' | 'consent'; /** Outcome bucket. */ status: 'ok' | 'error'; /** For /token, which grant_type was requested. */ grantType?: 'authorization_code' | 'refresh_token' | 'client_credentials' | 'unknown'; /** Client registration mode that resolved this request. */ clientType?: 'cimd' | 'dcr' | 'unknown'; /** For errors, the spec error code (invalid_grant, invalid_client, ...) for drill-down. */ errorCode?: string; }): void; /** * Record a CIMD metadata-fetch outcome. `cached=true` means the document * was served from the in-memory LRU without a network round-trip. */ export declare function recordCimdFetch(params: { status: 'ok' | 'error'; cached: boolean; errorCode?: string; }): void; /** * Returns true if OpenTelemetry metrics are available. */ export declare function isMetricsEnabled(): boolean; /** * Wait for the initial OTel probe. For tests. */ export declare function waitForMetricsProbe(): Promise; /** * Reset cached state. For tests only. */ export declare function _resetMetricsCache(): void; //# sourceMappingURL=metrics.d.ts.map