Include websocket users metric (#14020)
This commit adds new metrics to know the number of registered users we have in every WebSocket broadcasts hub
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cd382412fd
Коммит
ee86413cdd
@@ -161,6 +161,9 @@ func (a *App) GetHubForUserId(userId string) *Hub {
|
|||||||
func (a *App) HubRegister(webConn *WebConn) {
|
func (a *App) HubRegister(webConn *WebConn) {
|
||||||
hub := a.GetHubForUserId(webConn.UserId)
|
hub := a.GetHubForUserId(webConn.UserId)
|
||||||
if hub != nil {
|
if hub != nil {
|
||||||
|
if metrics := a.Metrics(); metrics != nil {
|
||||||
|
metrics.IncrementWebSocketBroadcastUsersRegistered(strconv.Itoa(hub.connectionIndex), 1)
|
||||||
|
}
|
||||||
hub.Register(webConn)
|
hub.Register(webConn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,6 +171,9 @@ func (a *App) HubRegister(webConn *WebConn) {
|
|||||||
func (a *App) HubUnregister(webConn *WebConn) {
|
func (a *App) HubUnregister(webConn *WebConn) {
|
||||||
hub := a.GetHubForUserId(webConn.UserId)
|
hub := a.GetHubForUserId(webConn.UserId)
|
||||||
if hub != nil {
|
if hub != nil {
|
||||||
|
if metrics := a.Metrics(); metrics != nil {
|
||||||
|
metrics.DecrementWebSocketBroadcastUsersRegistered(strconv.Itoa(hub.connectionIndex), 1)
|
||||||
|
}
|
||||||
hub.Unregister(webConn)
|
hub.Unregister(webConn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ type MetricsInterface interface {
|
|||||||
IncrementWebSocketBroadcast(eventType string)
|
IncrementWebSocketBroadcast(eventType string)
|
||||||
IncrementWebSocketBroadcastBufferSize(hub string, amount float64)
|
IncrementWebSocketBroadcastBufferSize(hub string, amount float64)
|
||||||
DecrementWebSocketBroadcastBufferSize(hub string, amount float64)
|
DecrementWebSocketBroadcastBufferSize(hub string, amount float64)
|
||||||
|
IncrementWebSocketBroadcastUsersRegistered(hub string, amount float64)
|
||||||
|
DecrementWebSocketBroadcastUsersRegistered(hub string, amount float64)
|
||||||
|
|
||||||
AddMemCacheHitCounter(cacheName string, amount float64)
|
AddMemCacheHitCounter(cacheName string, amount float64)
|
||||||
AddMemCacheMissCounter(cacheName string, amount float64)
|
AddMemCacheMissCounter(cacheName string, amount float64)
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ func (_m *MetricsInterface) DecrementWebSocketBroadcastBufferSize(hub string, am
|
|||||||
_m.Called(hub, amount)
|
_m.Called(hub, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DecrementWebSocketBroadcastUsersRegistered provides a mock function with given fields: hub, amount
|
||||||
|
func (_m *MetricsInterface) DecrementWebSocketBroadcastUsersRegistered(hub string, amount float64) {
|
||||||
|
_m.Called(hub, amount)
|
||||||
|
}
|
||||||
|
|
||||||
// IncrementChannelIndexCounter provides a mock function with given fields:
|
// IncrementChannelIndexCounter provides a mock function with given fields:
|
||||||
func (_m *MetricsInterface) IncrementChannelIndexCounter() {
|
func (_m *MetricsInterface) IncrementChannelIndexCounter() {
|
||||||
_m.Called()
|
_m.Called()
|
||||||
@@ -151,6 +156,11 @@ func (_m *MetricsInterface) IncrementWebSocketBroadcastBufferSize(hub string, am
|
|||||||
_m.Called(hub, amount)
|
_m.Called(hub, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IncrementWebSocketBroadcastUsersRegistered provides a mock function with given fields: hub, amount
|
||||||
|
func (_m *MetricsInterface) IncrementWebSocketBroadcastUsersRegistered(hub string, amount float64) {
|
||||||
|
_m.Called(hub, amount)
|
||||||
|
}
|
||||||
|
|
||||||
// IncrementWebhookPost provides a mock function with given fields:
|
// IncrementWebhookPost provides a mock function with given fields:
|
||||||
func (_m *MetricsInterface) IncrementWebhookPost() {
|
func (_m *MetricsInterface) IncrementWebhookPost() {
|
||||||
_m.Called()
|
_m.Called()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user