[MM-57010] Include client type in websocket connections metric (#26763)
* Include client type in websocket connections metric * Unexport field
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
effb99301e
Коммит
4b508eed46
@@ -67,6 +67,7 @@ type WebConnConfig struct {
|
||||
ConnectionID string
|
||||
Active bool
|
||||
ReuseCount int
|
||||
OriginClient string
|
||||
|
||||
// These aren't necessary to be exported to api layer.
|
||||
sequence int
|
||||
@@ -115,6 +116,9 @@ type WebConn struct {
|
||||
session atomic.Pointer[model.Session]
|
||||
connectionID atomic.Value
|
||||
|
||||
// The client type behind the connection (i.e. web, desktop or mobile)
|
||||
originClient string
|
||||
|
||||
activeChannelID atomic.Value
|
||||
activeTeamID atomic.Value
|
||||
activeRHSThreadChannelID atomic.Value
|
||||
@@ -236,6 +240,7 @@ func (ps *PlatformService) NewWebConn(cfg *WebConnConfig, suite SuiteIFace, runn
|
||||
pluginPosted: make(chan pluginWSPostedHook, 10),
|
||||
lastLogTimeSlow: time.Now(),
|
||||
lastLogTimeFull: time.Now(),
|
||||
originClient: cfg.OriginClient,
|
||||
}
|
||||
wc.active.Store(cfg.Active)
|
||||
|
||||
@@ -954,11 +959,13 @@ func (wc *WebConn) logSocketErr(source string, err error) {
|
||||
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
|
||||
mlog.Debug(source+": client side closed socket",
|
||||
mlog.String("user_id", wc.UserId),
|
||||
mlog.String("conn_id", wc.GetConnectionID()))
|
||||
mlog.String("conn_id", wc.GetConnectionID()),
|
||||
mlog.String("origin_client", wc.originClient))
|
||||
} else {
|
||||
mlog.Debug(source+": closing websocket",
|
||||
mlog.String("user_id", wc.UserId),
|
||||
mlog.String("conn_id", wc.GetConnectionID()),
|
||||
mlog.String("origin_client", wc.originClient),
|
||||
mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,6 +391,9 @@ func (h *Hub) Start() {
|
||||
|
||||
connIndex.Add(webConn)
|
||||
atomic.StoreInt64(&h.connectionCount, int64(connIndex.AllActive()))
|
||||
if metrics := h.platform.metricsIFace; metrics != nil {
|
||||
metrics.IncrementHTTPWebSockets(webConn.originClient)
|
||||
}
|
||||
|
||||
if webConn.IsAuthenticated() && webConn.reuseCount == 0 {
|
||||
// The hello message should only be sent when the reuseCount is 0.
|
||||
@@ -405,6 +408,9 @@ func (h *Hub) Start() {
|
||||
webConn.active.Store(false)
|
||||
|
||||
atomic.StoreInt64(&h.connectionCount, int64(connIndex.AllActive()))
|
||||
if metrics := h.platform.metricsIFace; metrics != nil {
|
||||
metrics.DecrementHTTPWebSockets(webConn.originClient)
|
||||
}
|
||||
|
||||
if webConn.UserId == "" {
|
||||
continue
|
||||
|
||||
Ссылка в новой задаче
Block a user