[MM-57066][MM-57329] Added metrics for all notification stopping points, consolidated categories between metrics and logging (#26799)

* [MM-57066] Add metric counters for notification events

* Some small changes

* Account for Metrics() sometimes being nil

* Fix test (again)

* Fix more tests

* A few changes from testing - added success counter

* Missed a mock

* Lint

* Add feature flag for notification monitoring
Этот коммит содержится в:
Devin Binnie
2024-04-18 10:30:08 -04:00
коммит произвёл GitHub
родитель 0ce5def8e2
Коммит 02e23a3275
26 изменённых файлов: 572 добавлений и 241 удалений

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

@@ -26,14 +26,38 @@ func ping(req *model.WebSocketRequest) (map[string]any, *model.AppError) {
func (api *API) websocketNotificationAck(req *model.WebSocketRequest) (map[string]any, *model.AppError) {
// Log the ACKs if necessary
api.App.NotificationsLog().Debug("Websocket notification acknowledgment",
mlog.String("type", model.TypeWebsocket),
mlog.String("type", model.NotificationTypeWebsocket),
mlog.String("user_id", req.Session.UserId),
mlog.Any("user_agent", req.Data["user_agent"]),
mlog.Any("post_id", req.Data["post_id"]),
mlog.Any("result", req.Data["result"]),
mlog.Any("status", req.Data["status"]),
mlog.Any("reason", req.Data["reason"]),
mlog.Any("data", req.Data["data"]),
)
// Count metrics for websocket acks
api.App.CountNotificationAck(model.NotificationTypeWebsocket)
status := req.Data["status"]
reason := req.Data["reason"]
if status == nil {
return nil, nil
}
notificationStatus := model.NotificationStatus(status.(string))
if reason == nil && notificationStatus != model.NotificationStatusSuccess {
return nil, nil
}
var notificationReason model.NotificationReason
if reason != nil {
notificationReason = model.NotificationReason(reason.(string))
}
api.App.CountNotificationReason(
notificationStatus,
model.NotificationTypeWebsocket,
notificationReason,
)
return nil, nil
}