/**
 * @module plugins/metrics
 * Metrics plugin for xBind plugin system
 *
 * Tracks performance metrics, message counts, and error rates.
 */
import type { Result } from '@private.me/shared';
import type { Plugin, PluginContext, HookResult } from '../plugin-system.js';
import type { AnyTransportEnvelope } from '../envelope.js';
/**
 * Metric entry structure.
 */
export interface MetricEntry {
    timestamp: number;
    event: 'send' | 'receive' | 'encrypt' | 'decrypt';
    duration: number;
    success: boolean;
    error?: string;
    metadata?: Record<string, unknown>;
}
/**
 * Aggregated metrics.
 */
export interface AggregatedMetrics {
    /** Total number of send operations */
    totalSends: number;
    /** Total number of receive operations */
    totalReceives: number;
    /** Total number of encrypt operations */
    totalEncrypts: number;
    /** Total number of decrypt operations */
    totalDecrypts: number;
    /** Average send duration (ms) */
    avgSendDuration: number;
    /** Average receive duration (ms) */
    avgReceiveDuration: number;
    /** Average encrypt duration (ms) */
    avgEncryptDuration: number;
    /** Average decrypt duration (ms) */
    avgDecryptDuration: number;
    /** Total errors */
    totalErrors: number;
    /** Error rate (0-1) */
    errorRate: number;
    /** Uptime (ms) */
    uptime: number;
}
/**
 * Metrics plugin options.
 */
export interface MetricsPluginOptions {
    /** Enable high-resolution timing (default: true) */
    highResolution?: boolean;
    /** Maximum metrics to store in memory (default: 10000) */
    maxMetrics?: number;
    /** Metrics export callback */
    onExport?: (metrics: MetricEntry[]) => void;
    /** Export interval in milliseconds (default: 60000 - 1 minute) */
    exportInterval?: number;
}
/**
 * Metrics plugin implementation.
 * Tracks performance and usage statistics for all operations.
 */
export declare class MetricsPlugin implements Plugin {
    readonly name = "metrics";
    readonly version = "1.0.0";
    readonly description = "Tracks performance metrics, message counts, and error rates";
    readonly priority = 20;
    private options;
    private metrics;
    private startTime;
    private exportTimer?;
    constructor(options?: MetricsPluginOptions);
    onInit(): Result<void, string>;
    onDestroy(): Result<void, string>;
    onSend(payload: unknown, _context: PluginContext): Result<HookResult<unknown>, string>;
    onReceive(envelope: AnyTransportEnvelope, _context: PluginContext): Result<HookResult<AnyTransportEnvelope>, string>;
    onEncrypt(plaintext: Uint8Array, _context: PluginContext): Result<HookResult<Uint8Array>, string>;
    onDecrypt(plaintext: Uint8Array, _context: PluginContext): Result<HookResult<Uint8Array>, string>;
    /**
     * Get all captured metrics.
     */
    getMetrics(): readonly MetricEntry[];
    /**
     * Get aggregated metrics summary.
     */
    getAggregatedMetrics(): AggregatedMetrics;
    /**
     * Clear all metrics.
     */
    clearMetrics(): void;
    /**
     * Export metrics using the configured callback.
     */
    export(): void;
    /**
     * Get metrics for a specific time range.
     */
    getMetricsInRange(startTime: number, endTime: number): MetricEntry[];
    /**
     * Get metrics for a specific event type.
     */
    getMetricsByEvent(event: 'send' | 'receive' | 'encrypt' | 'decrypt'): MetricEntry[];
    private record;
    private now;
}
/**
 * Create a metrics plugin with options.
 */
export declare function createMetricsPlugin(options?: MetricsPluginOptions): MetricsPlugin;
