- Fix metrics: change MessagesTotal, ConnectionsTotal, DisconnectionsTotal from Gauge to Counter with proper _total naming convention - Fix broadcast write-error handling: failed clients now get properly removed with accurate metrics updates - Add graceful shutdown: SIGINT/SIGTERM handling with 10s timeout, CloseGoingAway frame sent to clients before disconnect - Add integration tests: 11 tests using real WebSocket connections covering connect, broadcast, disconnect, concurrency, and shutdown - Fix example client port: changed from 8000 to 8443 to match config - Rewrite README.md to reflect current features and usage - Add AGENTS.md and .agents/summary/ documentation for AI assistants
29 lines
801 B
Go
29 lines
801 B
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
var (
|
|
ConnectedClients = promauto.NewGauge(prometheus.GaugeOpts{
|
|
Name: "websocket_connected_clients",
|
|
Help: "Number of currently connected WebSocket clients",
|
|
})
|
|
|
|
MessagesTotal = promauto.NewCounter(prometheus.CounterOpts{
|
|
Name: "websocket_messages_total",
|
|
Help: "Total number of WebSocket messages processed",
|
|
})
|
|
|
|
ConnectionsTotal = promauto.NewCounter(prometheus.CounterOpts{
|
|
Name: "websocket_connections_total",
|
|
Help: "Total number of WebSocket connections established",
|
|
})
|
|
|
|
DisconnectionsTotal = promauto.NewCounter(prometheus.CounterOpts{
|
|
Name: "websocket_disconnections_total",
|
|
Help: "Total number of WebSocket disconnections",
|
|
})
|
|
)
|