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

Commit 057cb31

Browse files
committed
show a warning when newrelic is not present/configured
1 parent 58de910 commit 057cb31

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

initializers/nrmid.js

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

53
var fixTransactionName = function(connection, actionTemplate, next) {
64
if(newrelic && connection.type === 'web'){
75
newrelic.setControllerName(actionTemplate.name);
86
}
97
next(connection, true);
10-
}
8+
};
119

1210
var reportException = function(type, err, extraMessages, severity){
1311
if(newrelic) newrelic.noticeError(err);
14-
}
12+
};
1513

1614
exports.nrmid = function(api, next){
15+
try {
16+
newrelic = require('newrelic');
17+
} catch (error) {
18+
api.log('Newrelic could not be initialized: ' + error, 'warning');
19+
newrelic = false;
20+
}
21+
1722
if(newrelic) {
1823
api.actions.preProcessors.push(fixTransactionName);
1924
api.exceptionHandlers.reporters.push(reportException);

0 commit comments

Comments
 (0)