savinmax 905c241daa
Some checks failed
CI / test (push) Successful in 54s
CI / lint (push) Failing after 3m16s
Improve reliability, testing, and documentation
- 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
2026-06-11 19:14:19 +02:00

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",
})
)