fix(metrics): improve metrics
This commit is contained in:
@ -29,7 +29,7 @@ import { AcmeStateManager } from './acme-state-manager.js';
|
||||
|
||||
// Import metrics collector
|
||||
import { MetricsCollector } from './metrics-collector.js';
|
||||
import type { IProxyStats } from './models/metrics-types.js';
|
||||
import type { IMetrics } from './models/metrics-types.js';
|
||||
|
||||
/**
|
||||
* SmartProxy - Pure route-based API
|
||||
@ -52,24 +52,24 @@ export class SmartProxy extends plugins.EventEmitter {
|
||||
|
||||
// Component managers
|
||||
public connectionManager: ConnectionManager;
|
||||
private securityManager: SecurityManager;
|
||||
private tlsManager: TlsManager;
|
||||
private httpProxyBridge: HttpProxyBridge;
|
||||
private timeoutManager: TimeoutManager;
|
||||
public routeManager: RouteManager; // Made public for route management
|
||||
public routeConnectionHandler: RouteConnectionHandler; // Made public for metrics
|
||||
private nftablesManager: NFTablesManager;
|
||||
public securityManager: SecurityManager;
|
||||
public tlsManager: TlsManager;
|
||||
public httpProxyBridge: HttpProxyBridge;
|
||||
public timeoutManager: TimeoutManager;
|
||||
public routeManager: RouteManager;
|
||||
public routeConnectionHandler: RouteConnectionHandler;
|
||||
public nftablesManager: NFTablesManager;
|
||||
|
||||
// Certificate manager for ACME and static certificates
|
||||
private certManager: SmartCertManager | null = null;
|
||||
public certManager: SmartCertManager | null = null;
|
||||
|
||||
// Global challenge route tracking
|
||||
private globalChallengeRouteActive: boolean = false;
|
||||
private routeUpdateLock: any = null; // Will be initialized as AsyncMutex
|
||||
private acmeStateManager: AcmeStateManager;
|
||||
public acmeStateManager: AcmeStateManager;
|
||||
|
||||
// Metrics collector
|
||||
private metricsCollector: MetricsCollector;
|
||||
public metricsCollector: MetricsCollector;
|
||||
|
||||
// Track port usage across route updates
|
||||
private portUsageMap: Map<number, Set<string>> = new Map();
|
||||
@ -161,13 +161,9 @@ export class SmartProxy extends plugins.EventEmitter {
|
||||
}
|
||||
|
||||
// Initialize component managers
|
||||
this.timeoutManager = new TimeoutManager(this.settings);
|
||||
this.securityManager = new SecurityManager(this.settings);
|
||||
this.connectionManager = new ConnectionManager(
|
||||
this.settings,
|
||||
this.securityManager,
|
||||
this.timeoutManager
|
||||
);
|
||||
this.timeoutManager = new TimeoutManager(this);
|
||||
this.securityManager = new SecurityManager(this);
|
||||
this.connectionManager = new ConnectionManager(this);
|
||||
|
||||
// Create the route manager with SharedRouteManager API
|
||||
// Create a logger adapter to match ILogger interface
|
||||
@ -186,25 +182,17 @@ export class SmartProxy extends plugins.EventEmitter {
|
||||
|
||||
|
||||
// Create other required components
|
||||
this.tlsManager = new TlsManager(this.settings);
|
||||
this.httpProxyBridge = new HttpProxyBridge(this.settings);
|
||||
this.tlsManager = new TlsManager(this);
|
||||
this.httpProxyBridge = new HttpProxyBridge(this);
|
||||
|
||||
// Initialize connection handler with route support
|
||||
this.routeConnectionHandler = new RouteConnectionHandler(
|
||||
this.settings,
|
||||
this.connectionManager,
|
||||
this.securityManager,
|
||||
this.tlsManager,
|
||||
this.httpProxyBridge,
|
||||
this.timeoutManager,
|
||||
this.routeManager
|
||||
);
|
||||
this.routeConnectionHandler = new RouteConnectionHandler(this);
|
||||
|
||||
// Initialize port manager
|
||||
this.portManager = new PortManager(this.settings, this.routeConnectionHandler);
|
||||
this.portManager = new PortManager(this);
|
||||
|
||||
// Initialize NFTablesManager
|
||||
this.nftablesManager = new NFTablesManager(this.settings);
|
||||
this.nftablesManager = new NFTablesManager(this);
|
||||
|
||||
// Initialize route update mutex for synchronization
|
||||
this.routeUpdateLock = new Mutex();
|
||||
@ -922,11 +910,11 @@ export class SmartProxy extends plugins.EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get proxy statistics and metrics
|
||||
* Get proxy metrics with clean API
|
||||
*
|
||||
* @returns IProxyStats interface with various metrics methods
|
||||
* @returns IMetrics interface with grouped metrics methods
|
||||
*/
|
||||
public getStats(): IProxyStats {
|
||||
public getMetrics(): IMetrics {
|
||||
return this.metricsCollector;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user