diff --git a/network/client.go b/network/client.go index c71e2f38..27c119a4 100644 --- a/network/client.go +++ b/network/client.go @@ -236,6 +236,8 @@ func (c *Client) Reconnect() error { if c.conn != nil { c.Close() + } else { + metrics.ServerConnections.Dec() } c.connected.Store(false) diff --git a/network/server_test.go b/network/server_test.go index 4dbb7d24..9b0643c2 100644 --- a/network/server_test.go +++ b/network/server_test.go @@ -16,6 +16,7 @@ import ( "github.com/gatewayd-io/gatewayd/logging" "github.com/gatewayd-io/gatewayd/plugin" "github.com/gatewayd-io/gatewayd/pool" + "github.com/prometheus/client_golang/prometheus" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "google.golang.org/grpc" @@ -25,6 +26,9 @@ import ( func TestRunServer(t *testing.T) { errs := make(chan error) + // Reset prometheus metrics. + prometheus.DefaultRegisterer = prometheus.NewRegistry() + logger := logging.NewLogger(context.Background(), logging.LoggerConfig{ Output: []config.LogOutput{ config.File,