diff --git a/server.go b/server.go index f77269d..bf47f6d 100644 --- a/server.go +++ b/server.go @@ -106,6 +106,8 @@ type Server struct { upstreamInMessagesTotal prometheus.Counter downstreamOutMessagesTotal prometheus.Counter downstreamInMessagesTotal prometheus.Counter + + upstreamConnectErrorsTotal prometheus.Counter } } @@ -195,6 +197,11 @@ func (s *Server) registerMetrics() { Name: "soju_downstream_in_messages_total", Help: "Total number of incoming messages received from downstream clients", }) + + s.metrics.upstreamConnectErrorsTotal = factory.NewCounter(prometheus.CounterOpts{ + Name: "soju_upstream_connect_errors_total", + Help: "Total number of upstream connection errors", + }) } func (s *Server) Shutdown() { diff --git a/user.go b/user.go index 84c7b0c..9839bcf 100644 --- a/user.go +++ b/user.go @@ -209,6 +209,7 @@ func (net *network) run() { net.logger.Printf("failed to connect to upstream server %q: %v", net.Addr, err) net.user.events <- eventUpstreamConnectionError{net, fmt.Errorf("failed to connect: %v", err)} net.user.srv.metrics.upstreams.Add(-1) + net.user.srv.metrics.upstreamConnectErrorsTotal.Inc() continue } @@ -226,6 +227,7 @@ func (net *network) run() { net.user.events <- eventUpstreamConnectionError{net, fmt.Errorf("failed to register: %v", text)} uc.Close() net.user.srv.metrics.upstreams.Add(-1) + net.user.srv.metrics.upstreamConnectErrorsTotal.Inc() continue }