[MM-64244] Add websocket disconnect reason metric (#31032)

We've recently spent some effort improving websocket reconnection logic. With this commit, I've augmented the websocket reconnect metric to include a disconnect reason. This will help us measure the impact of these changes in production.
Этот коммит содержится в:
David Krauser
2025-05-30 08:15:20 -04:00
коммит произвёл GitHub
родитель 611b2a8e79
Коммит 761584c040
9 изменённых файлов: 215 добавлений и 41 удалений

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

@@ -726,7 +726,7 @@ func New(ps *platform.PlatformService, driver, dataSource string) *MetricsInterf
Help: "Total number of websocket reconnect attempts",
ConstLabels: additionalLabels,
},
[]string{"type"},
[]string{"type", "disconnect_err_code"},
)
m.Registry.MustRegister(m.WebSocketReconnectCounter)
@@ -1822,8 +1822,14 @@ func (mi *MetricsInterfaceImpl) IncrementWebsocketEvent(eventType model.Websocke
mi.WebsocketEventCounters.With(prometheus.Labels{"type": string(eventType)}).Inc()
}
func (mi *MetricsInterfaceImpl) IncrementWebsocketReconnectEvent(eventType string) {
mi.WebSocketReconnectCounter.With(prometheus.Labels{"type": eventType}).Inc()
func (mi *MetricsInterfaceImpl) IncrementWebsocketReconnectEventWithDisconnectErrCode(eventType string, disconnectErrCode string) {
if disconnectErrCode == "" {
disconnectErrCode = "unknown"
}
mi.WebSocketReconnectCounter.With(prometheus.Labels{
"type": eventType,
"disconnect_err_code": disconnectErrCode,
}).Inc()
}
func (mi *MetricsInterfaceImpl) IncrementWebSocketBroadcastBufferSize(hub string, amount float64) {