Skip to content

Commit

Permalink
Prometheus: Track user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed May 18, 2018
1 parent b634ed0 commit 0884ebc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/rocketchat-api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ class API extends Restivus {
const rocketchatRestApiEnd = RocketChat.metrics.rocketchatRestApi.startTimer({
method,
version,
user_agent: this.request.headers['user-agent'],
entrypoint: route
});

this.logger.debug(`${ this.request.method.toUpperCase() }: ${ this.request.url }`);
let result;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function shouldNotifyAudio({
}

export function notifyAudioUser(userId, message, room) {
RocketChat.metrics.notificationsSent.inc({ notification_type: 'audio' }, 1, new Date());
RocketChat.metrics.notificationsSent.inc({ notification_type: 'audio' });
RocketChat.Notifications.notifyUser(userId, 'audioNotification', {
payload: {
_id: message._id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function notifyDesktopUser({
return;
}

RocketChat.metrics.notificationsSent.inc({ notification_type: 'desktop' }, 1, new Date());
RocketChat.metrics.notificationsSent.inc({ notification_type: 'desktop' });
RocketChat.Notifications.notifyUser(userId, 'notification', {
title,
text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function sendEmail({ message, user, subscription, room, emailAddress, toA
}

Meteor.defer(() => {
RocketChat.metrics.notificationsSent.inc({ notification_type: 'email' }, 1, new Date());
RocketChat.metrics.notificationsSent.inc({ notification_type: 'email' });
Email.send(email);
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/lib/PushNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PushNotification {
};
}

RocketChat.metrics.notificationsSent.inc({ notification_type: 'mobile' }, 1, new Date());
RocketChat.metrics.notificationsSent.inc({ notification_type: 'mobile' });
return Push.send(config);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/lib/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RocketChat.metrics.rocketchatHooks = new client.Summary({
RocketChat.metrics.rocketchatRestApi = new client.Summary({
name: 'rocketchat_rest_api',
help: 'summary of rocketchat rest api count and time',
labelNames: ['method', 'entrypoint', 'status', 'version']
labelNames: ['method', 'entrypoint', 'user_agent', 'status', 'version']
});

RocketChat.metrics.meteorSubscriptions = new client.Summary({
Expand Down

0 comments on commit 0884ebc

Please sign in to comment.