Skip to content
Snippets Groups Projects
Commit c5b2d69a authored by Sean McArthur's avatar Sean McArthur
Browse files

moved node-statsd to optionalDependency

also prevents error from require node-statsd if it wasn't installed,
but logs error if config says it should be enabled.
parent ff995941
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const
StatsD = require("node-statsd").StatsD,
config = require('./configuration');
config = require('./configuration'),
logger = require('./logging').logger;
var StatsD = false;
try {
StatsD = require("node-statsd").StatsD;
} catch (requireError) {
// its ok, its an optionalDependency
}
const PREFIX = "browserid." + config.get('process_type') + ".";
......@@ -23,11 +30,15 @@ module.exports = {
var statsd_config = config.get('statsd');
if (statsd_config && statsd_config.enabled) {
var options = {};
options["host"] = options["host"] || "localhost";
options["port"] = options["port"] || 8125;
statsd = new StatsD(options["host"], options["port"]);
if (StatsD) {
var options = {};
options["host"] = options["host"] || "localhost";
options["port"] = options["port"] || 8125;
statsd = new StatsD(options["host"], options["port"]);
} else {
log.error('statsd config enabled, but node-statsd not installed.');
}
}
process.on('uncaughtException', function(err) {
......
......@@ -20,7 +20,6 @@
"mustache": "0.3.1-dev",
"jwcrypto": "0.3.2",
"mysql": "0.9.5",
"node-statsd": "https://github.com/downloads/lloyd/node-statsd/0509f85.tgz",
"nodemailer": "0.1.24",
"mkdirp": "0.3.0",
"optimist": "0.2.8",
......@@ -34,6 +33,9 @@
"validator": "0.4.9",
"winston": "0.6.2"
},
"optionalDependencies": {
"node-statsd": "https://github.com/downloads/lloyd/node-statsd/0509f85.tgz"
},
"devDependencies": {
"vows": "0.5.13",
"awsbox": "0.2.12",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment