feat(metrics): add per-backend connection, error, protocol, and pool metrics with stale backend pruning

This commit is contained in:
2026-03-12 15:16:11 +00:00
parent 0380a957d0
commit 0d4399d7f1
7 changed files with 561 additions and 36 deletions

View File

@@ -67,6 +67,13 @@ export interface IMetrics {
connections(): number;
};
// Backend metrics
backends: {
byBackend(): Map<string, IBackendMetrics>;
protocols(): Map<string, string>;
topByErrors(limit?: number): Array<{ backend: string; errors: number }>;
};
// Performance metrics
percentiles: {
connectionDuration(): { p50: number; p95: number; p99: number };
@@ -98,6 +105,21 @@ export interface IMetricsConfig {
prometheusPrefix: string; // Default: smartproxy_
}
/**
* Per-backend metrics
*/
export interface IBackendMetrics {
protocol: string;
activeConnections: number;
totalConnections: number;
connectErrors: number;
handshakeErrors: number;
requestErrors: number;
avgConnectTimeMs: number;
poolHitRate: number;
h2Failures: number;
}
/**
* Internal interface for connection byte tracking
*/