feat: add missing metrics for dashboard compatibility

Added new metrics:
- active_connections: Number of active WhatsApp connections
- connection_errors_total: Total connection errors by type
- buffer_destroyed_total: Total buffers destroyed
- buffer_final_flush_total: Final flushes during destruction
- buffer_cache_cleanup_total: Cache cleanup operations
- buffer_cache_size: Current buffer cache size
- adaptive_health_status: System health (0=unhealthy, 1=healthy)
- adaptive_event_rate: Current event rate per second

These metrics are required for the Grafana dashboard to display all panels correctly.
This commit is contained in:
Claude
2026-01-22 11:57:23 +00:00
parent b5b43b5fd6
commit ee80d2cdf8
+24
View File
@@ -1391,6 +1391,12 @@ export const metrics = {
connectionLatency: baileysMetrics.register(
new Histogram('connection_latency_ms', 'Connection establishment latency in ms', [], [100, 250, 500, 1000, 2500, 5000, 10000])
),
activeConnections: baileysMetrics.register(
new Gauge('active_connections', 'Number of active WhatsApp connections')
),
connectionErrors: baileysMetrics.register(
new Counter('connection_errors_total', 'Total connection errors', ['error_type'])
),
// ========== Message Metrics ==========
messagesSent: baileysMetrics.register(
@@ -1472,6 +1478,18 @@ export const metrics = {
eventsProcessed: baileysMetrics.register(
new Counter('events_processed_total', 'Total events processed from buffer', ['event_type'])
),
bufferDestroyed: baileysMetrics.register(
new Counter('buffer_destroyed_total', 'Total buffers destroyed', ['reason', 'had_pending_flush'])
),
bufferFinalFlush: baileysMetrics.register(
new Counter('buffer_final_flush_total', 'Total final flushes during destruction')
),
bufferCacheCleanup: baileysMetrics.register(
new Counter('buffer_cache_cleanup_total', 'Total cache cleanup operations')
),
bufferCacheSize: baileysMetrics.register(
new Gauge('buffer_cache_size', 'Current buffer cache size')
),
// ========== Adaptive Flush Metrics ==========
adaptiveFlushInterval: baileysMetrics.register(
@@ -1489,6 +1507,12 @@ export const metrics = {
adaptiveFlushEfficiency: baileysMetrics.register(
new Gauge('adaptive_flush_efficiency_percent', 'Flush efficiency percentage')
),
adaptiveHealthStatus: baileysMetrics.register(
new Gauge('adaptive_health_status', 'Adaptive system health status (0=unhealthy, 1=healthy)')
),
adaptiveEventRate: baileysMetrics.register(
new Gauge('adaptive_event_rate', 'Current event rate per second')
),
// ========== Error Metrics ==========
errors: baileysMetrics.register(