Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit d2f889a

Browse files
committed
allow dev instances to go uninstrumented by newrelic
1 parent fff741f commit d2f889a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

initializers/nrmid.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
var newrelic = require("newrelic");
1+
try {
2+
var newrelic = require("newrelic");
3+
} catch (ignore) { }
24

35
var fixTransactionName = function(connection, actionTemplate, next) {
4-
if(connection.type === 'web'){
6+
if(newrelic && connection.type === 'web'){
57
newrelic.setControllerName(actionTemplate.name);
68
}
79
next(connection, true);
810
}
911

1012
var reportException = function(type, err, extraMessages, severity){
11-
newrelic.noticeError(err);
13+
if(newrelic) newrelic.noticeError(err);
1214
}
1315

1416
exports.nrmid = function(api, next){
15-
api.actions.preProcessors.push(fixTransactionName);
16-
api.exceptionHandlers.reporters.push(reportException);
17+
if(newrelic) {
18+
api.actions.preProcessors.push(fixTransactionName);
19+
api.exceptionHandlers.reporters.push(reportException);
20+
}
1721
next();
1822
};

0 commit comments

Comments
 (0)