Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
windycrypto committed Nov 27, 2023
1 parent accf14d commit c59f768
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions metrics/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ var (
Name: "send_blockings",
Help: "Number of send blocking connections",
})

countMessageFromClosed = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: promNamespace,
Subsystem: promSubsystem,
Name: "sending_on_closed",
Help: "Number of sending on closed connections",
})
)

func IncNewConnection() {
Expand All @@ -44,6 +51,10 @@ func IncSendBlocking() {
countSendBlocking.Inc()
}

func IncMessageFromClosed() {
countMessageFromClosed.Inc()
}

func SetCurrentConnections(num int) {
gaugeCurrentConnections.Set(float64(num))
}
Expand Down
3 changes: 3 additions & 0 deletions relay/wsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func (ws *WsServer) Run() {
for {
select {
case message := <-ws.localCh:
if _, ok := ws.clients[message.client]; !ok {
metrics.IncMessageFromClosed()
}
// local message could be "pub", "sub" or "ack" or "ping"
// pub/sub message handler may contain time-consuming operations(e.g. read/write redis)
// so put them in separate goroutine to avoid blocking wsserver main loop
Expand Down

0 comments on commit c59f768

Please sign in to comment.