Added Websocket's broadcast queue load metrics (#13935)

Now we send metrics when the websocket's broadcast queue receive or
consume a message from the queue
Этот коммит содержится в:
Mario de Frutos Dieguez
2020-02-28 11:44:56 +01:00
коммит произвёл GitHub
родитель b07898b8a2
Коммит 75197d291a
3 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@@ -343,6 +343,9 @@ func (h *Hub) Unregister(webConn *WebConn) {
func (h *Hub) Broadcast(message *model.WebSocketEvent) {
if h != nil && h.broadcast != nil && message != nil {
if metrics := h.app.Metrics(); metrics != nil {
metrics.IncrementWebSocketBroadcastBufferSize(strconv.Itoa(h.connectionIndex), 1)
}
select {
case h.broadcast <- message:
case <-h.didStop:
@@ -433,6 +436,9 @@ func (h *Hub) Start() {
}
}
case msg := <-h.broadcast:
if metrics := h.app.Metrics(); metrics != nil {
metrics.DecrementWebSocketBroadcastBufferSize(strconv.Itoa(h.connectionIndex), 1)
}
candidates := connections.All()
if msg.GetBroadcast().UserId != "" {
candidates = connections.ForUser(msg.GetBroadcast().UserId)