diff --git a/packages/rocketchat-lib/server/functions/notifications/audio.js b/packages/rocketchat-lib/server/functions/notifications/audio.js index aac7fc14c2d2..4c5e94fce8df 100644 --- a/packages/rocketchat-lib/server/functions/notifications/audio.js +++ b/packages/rocketchat-lib/server/functions/notifications/audio.js @@ -24,7 +24,7 @@ export function shouldNotifyAudio({ } export function notifyAudioUser(userId, message, room) { - RocketChat.metrics.audioNotificationsSent.inc(); + RocketChat.metrics.notificationsSent.inc({ type: 'audio' }, 1, new Date()); RocketChat.Notifications.notifyUser(userId, 'audioNotification', { payload: { _id: message._id, diff --git a/packages/rocketchat-lib/server/functions/notifications/desktop.js b/packages/rocketchat-lib/server/functions/notifications/desktop.js index 6f5fe8c1f0b6..bcc38de01f34 100644 --- a/packages/rocketchat-lib/server/functions/notifications/desktop.js +++ b/packages/rocketchat-lib/server/functions/notifications/desktop.js @@ -30,7 +30,7 @@ export function notifyDesktopUser({ return; } - RocketChat.metrics.desktopNotificationsSent.inc(); + RocketChat.metrics.notificationsSent.inc({ type: 'desktop' }, 1, new Date()); RocketChat.Notifications.notifyUser(userId, 'notification', { title, text, diff --git a/packages/rocketchat-lib/server/functions/notifications/email.js b/packages/rocketchat-lib/server/functions/notifications/email.js index 21b7fda83839..6350cef2f349 100644 --- a/packages/rocketchat-lib/server/functions/notifications/email.js +++ b/packages/rocketchat-lib/server/functions/notifications/email.js @@ -137,7 +137,7 @@ export function sendEmail({ message, user, subscription, room, emailAddress, toA } Meteor.defer(() => { - RocketChat.metrics.emailNotificationsSent.inc(); + RocketChat.metrics.notificationsSent.inc({ type: 'email' }, 1, new Date()); Email.send(email); }); } diff --git a/packages/rocketchat-lib/server/lib/PushNotification.js b/packages/rocketchat-lib/server/lib/PushNotification.js index db3ff9137a00..fc9b7ef4e8b3 100644 --- a/packages/rocketchat-lib/server/lib/PushNotification.js +++ b/packages/rocketchat-lib/server/lib/PushNotification.js @@ -47,7 +47,7 @@ class PushNotification { }; } - RocketChat.metrics.mobileNotificationsSent.inc(); + RocketChat.metrics.notificationsSent.inc({ type: 'mobile' }, 1, new Date()); return Push.send(config); } } diff --git a/packages/rocketchat-lib/server/lib/metrics.js b/packages/rocketchat-lib/server/lib/metrics.js index 21dcad0bf992..ba14a953fe12 100644 --- a/packages/rocketchat-lib/server/lib/metrics.js +++ b/packages/rocketchat-lib/server/lib/metrics.js @@ -38,10 +38,7 @@ RocketChat.metrics.meteorSubscriptions = new client.Summary({ }); RocketChat.metrics.messagesSent = new client.Counter({'name': 'message_sent', 'help': 'cumulated number of messages sent'}); -RocketChat.metrics.audioNotificationsSent = new client.Counter({'name': 'audio_sent', 'help': 'cumulated number of audio notifications sent'}); -RocketChat.metrics.desktopNotificationsSent = new client.Counter({'name': 'desktop_sent', 'help': 'cumulated number of desktop notifications sent'}); -RocketChat.metrics.mobileNotificationsSent = new client.Counter({'name': 'mobile_sent', 'help': 'cumulated number of mobile notifications sent'}); -RocketChat.metrics.emailNotificationsSent = new client.Counter({'name': 'email_sent', 'help': 'cumulated number of email notifications sent'}); +RocketChat.metrics.notificationsSent = new client.Counter({'name': 'notification_sent', labelNames: ['type'], 'help': 'cumulated number of notifications sent'}); RocketChat.metrics.ddpSessions = new client.Gauge({'name': 'ddp_sessions_count', 'help': 'number of open ddp sessions'}); RocketChat.metrics.ddpConnectedUsers = new client.Gauge({'name': 'ddp_connected_users', 'help': 'number of connected users'});