/**
 * Database Metrics Wrapper
 *
 * Provides instrumentation for database operations, capturing query timing,
 * success/failure counts, and connection pool metrics.
 */
import type { Pool, PoolClient, QueryResult, QueryResultRow } from 'pg';
import { type DbOperationType } from '../intent/metrics.js';
/**
 * Wraps a pg Pool to instrument queries with metrics
 */
export declare class InstrumentedPool {
    private pool;
    private metricsInterval;
    constructor(pool: Pool);
    /**
     * Start periodic collection of pool metrics
     */
    startMetricsCollection(intervalMs?: number): void;
    /**
     * Stop periodic metrics collection
     */
    stopMetricsCollection(): void;
    /**
     * Collect current pool metrics
     */
    collectPoolMetrics(): void;
    /**
     * Execute a query with metrics instrumentation
     */
    query<R extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<QueryResult<R>>;
    /**
     * Get an instrumented client from the pool
     */
    connect(): Promise<InstrumentedPoolClient>;
    /**
     * Get the underlying pool (for advanced usage)
     */
    getPool(): Pool;
    /**
     * End the pool connection
     */
    end(): Promise<void>;
}
/**
 * Wraps a pg PoolClient to instrument queries with metrics
 */
export declare class InstrumentedPoolClient {
    private client;
    constructor(client: PoolClient);
    /**
     * Execute a query with metrics instrumentation
     */
    query<R extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): Promise<QueryResult<R>>;
    /**
     * Release the client back to the pool
     */
    release(err?: Error | boolean): void;
    /**
     * Get the underlying client (for advanced usage)
     */
    getClient(): PoolClient;
}
/**
 * Wrap a database query function with metrics instrumentation.
 * Useful for instrumenting existing code without changing structure.
 */
export declare function withDbMetrics<T>(operation: DbOperationType, queryFn: () => Promise<T>): Promise<T>;
/**
 * Timer helper for measuring query duration.
 * Useful for instrumenting Drizzle ORM queries.
 */
export declare class DbQueryTimer {
    private startTime;
    private operation;
    constructor(operation: DbOperationType);
    /**
     * Record success and return the duration in seconds
     */
    success(): number;
    /**
     * Record failure
     */
    failure(error: unknown): void;
}
/**
 * Create a timer for measuring query duration
 */
export declare function startDbQueryTimer(operation: DbOperationType): DbQueryTimer;
//# sourceMappingURL=db-metrics.d.ts.map