Skip to content

Commit

Permalink
Merge e4eb690 into 031723a
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Sánchez committed Feb 2, 2018
2 parents 031723a + e4eb690 commit 63ca87c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/hapi-statsd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var StatsdClient = require('statsd-client'),
port: '8125',
prefix: 'hapi',
pathSeparator: '_',
template: '{path}.{method}.{statusCode}'
template: '{path}.{method}.{statusCode}',
includeMetricTypeInName: false
};

var register = function (server, options) {
Expand Down Expand Up @@ -44,10 +45,12 @@ var register = function (server, options) {
.replace('{path}', normalizePath(path))
.replace('{method}', request.method.toUpperCase())
.replace('{statusCode}', statusCode);
var incrementSuffix = settings.includeMetricTypeInName ? '.counter' : '';
var timingSuffix = settings.includeMetricTypeInName ? '.timer' : '';

statName = (statName.indexOf('.') === 0) ? statName.substr(1) : statName;
statsdClient.increment(statName);
statsdClient.timing(statName, startDate);
statsdClient.increment(statName + incrementSuffix);
statsdClient.timing(statName + timingSuffix, startDate);

return h.continue;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"contributors": [
"Mac Angell <mac.ang311@gmail.com>"
],
"version": "7.0.0",
"version": "8.0.0",
"dependencies": {
"statsd-client": "^0.2.4",
"hoek": "^5.0.2"
Expand Down

0 comments on commit 63ca87c

Please sign in to comment.