Skip to content

Commit eeade9c

Browse files
committed
add datadog to count number of hooks events
1 parent 62ddc38 commit eeade9c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/routes/actions/github.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var pluck = require('101/pluck');
2929
var noop = require('101/noop');
3030
var error = require('error');
3131
var github = require('middlewares/apis').github;
32+
var dogstatsd = require('models/datadog');
3233

3334
/** Receive the Github hooks
3435
* @event POST rest/actions/github
@@ -43,6 +44,7 @@ var pushSessionUser = {
4344
};
4445

4546
app.post('/actions/github/',
47+
reportDatadogEvent,
4648
mw.headers('user-agent').require().matches(/^GitHub.*$/),
4749
mw.headers('x-github-event', 'x-github-delivery').require(),
4850
mw.headers('x-github-event').matches(/^ping$/).then(
@@ -141,6 +143,13 @@ app.post('/actions/github/',
141143
mw.res.status(202),
142144
mw.res.send('No action set up for that payload.'));
143145

146+
147+
function reportDatadogEvent (req, res, next) {
148+
var eventName = req.get('x-github-event') || '';
149+
dogstatsd.increment('api.actions.github.events', ['event:' + eventName]);
150+
next();
151+
}
152+
144153
function parseGitHubPRData (req, res, next) {
145154
var repository = keypather.get(req, 'body.repository');
146155
if (!repository) {

0 commit comments

Comments
 (0)