Add soju_upstream_connect_errors_total metric

This commit is contained in:
Simon Ser 2021-12-02 11:15:51 +01:00
parent d11216917b
commit 8acc07d591
2 changed files with 9 additions and 0 deletions

View File

@ -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() {

View File

@ -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
}