From d2f889a24d2ba4b0ddd6a674880dbd9f822d6823 Mon Sep 17 00:00:00 2001 From: Thabo Date: Wed, 8 Apr 2015 16:51:15 -0700 Subject: [PATCH] allow dev instances to go uninstrumented by newrelic --- initializers/nrmid.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/initializers/nrmid.js b/initializers/nrmid.js index f5a06ac2f..69cca1a09 100644 --- a/initializers/nrmid.js +++ b/initializers/nrmid.js @@ -1,18 +1,22 @@ -var newrelic = require("newrelic"); +try { + var newrelic = require("newrelic"); +} catch (ignore) { } var fixTransactionName = function(connection, actionTemplate, next) { - if(connection.type === 'web'){ + if(newrelic && connection.type === 'web'){ newrelic.setControllerName(actionTemplate.name); } next(connection, true); } var reportException = function(type, err, extraMessages, severity){ - newrelic.noticeError(err); + if(newrelic) newrelic.noticeError(err); } exports.nrmid = function(api, next){ - api.actions.preProcessors.push(fixTransactionName); - api.exceptionHandlers.reporters.push(reportException); + if(newrelic) { + api.actions.preProcessors.push(fixTransactionName); + api.exceptionHandlers.reporters.push(reportException); + } next(); }; \ No newline at end of file