Skip to content

Commit

Permalink
Fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Oct 15, 2023
1 parent f02a31f commit e904023
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions network/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ func (c *Client) Reconnect() error {

if c.conn != nil {
c.Close()
} else {
metrics.ServerConnections.Dec()
}
c.connected.Store(false)

Expand Down
2 changes: 1 addition & 1 deletion network/network_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func CollectAndComparePrometheusMetrics(t *testing.T) {
gatewayd_proxy_passthrough_terminations_total 0
gatewayd_proxy_passthroughs_to_client_total 1
gatewayd_proxy_passthroughs_to_server_total 1
gatewayd_server_connections 5
gatewayd_server_connections 4
gatewayd_traffic_bytes_sum 182
gatewayd_traffic_bytes_count 4
gatewayd_server_ticks_fired_total 1
Expand Down
4 changes: 4 additions & 0 deletions network/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down

0 comments on commit e904023

Please sign in to comment.