From c16062ae40e817a5fd85fbefe82f8902c5372bde Mon Sep 17 00:00:00 2001 From: zikaeroh <48577114+zikaeroh@users.noreply.github.com> Date: Fri, 12 Jun 2020 21:16:24 -0700 Subject: [PATCH] Attempt to track the disconnect bug --- frontend/src/pages/game.tsx | 2 +- internal/server/metrics.go | 7 +++++++ internal/server/server.go | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/game.tsx b/frontend/src/pages/game.tsx index b65a034..4158d10 100644 --- a/frontend/src/pages/game.tsx +++ b/frontend/src/pages/game.tsx @@ -56,7 +56,7 @@ function usePlayer(playerID: string, state?: State): { pState: StatePlayer; pTea }, [playerID, state]); } -const reconnectAttempts = 5; +const reconnectAttempts = 2; function useWS(roomID: string, playerID: string, nickname: string, dead: () => void, onOpen: () => void) { const didUnmount = React.useRef(false); diff --git a/internal/server/metrics.go b/internal/server/metrics.go index cfd60c6..a79ab6d 100644 --- a/internal/server/metrics.go +++ b/internal/server/metrics.go @@ -33,4 +33,11 @@ var ( Name: "sent_total", Help: "Total number of sent messages.", }) + + metricHandleErrors = promauto.NewCounter(prometheus.CounterOpts{ + Namespace: "codies", + Subsystem: "codies", + Name: "handle_error_total", + Help: "Total number of handle errors.", + }) ) diff --git a/internal/server/server.go b/internal/server/server.go index dd96867..fece661 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -297,6 +297,7 @@ func (r *Room) HandleConn(playerID uuid.UUID, nickname string, c *websocket.Conn metricReceived.Inc() if err := r.handleNote(playerID, ¬e); err != nil { + metricHandleErrors.Inc() log.Println("error handling note:", err) return err }