-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
70 lines (61 loc) · 2.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var fs = require('fs'),
path = require('path');
var newrelicFile = path.join(process.cwd(), 'newrelic.js');
if (fs.existsSync(newrelicFile) && !process.env.NO_EXT_MONITOR) {
var newrelicInfo = require(newrelicFile);
console.log('Using newrelic: ' + JSON.stringify(newrelicInfo));
var nr = require('newrelic');
var config;
return module.exports = {
init: function(_config) {
config = _config;
},
recordMetric: function(ns, val) {
nr.recordMetric(ns, val);
},
noticeError: function(err, customParameters) {
nr.noticeError(err, customParameters);
},
getTransaction: function() {
return nr.getTransaction();
},
endTransaction: function() {
nr.endTransaction();
},
createWebTransaction: function(url, handle) {
return nr.startWebTransaction(url, handle);
},
createBackgroundTransaction: function(name, group, handle) {
return nr.startBackgroundTransaction(name, group, handle);
},
addCustomParameter: function(name, value){
nr.addCustomAttribute(name, value);
},
recordCustomEvent: function(name, value){
nr.recordCustomEvent(name, value);
},
startSegment: function(name, record, handler, callback) {
return nr.startSegment(name, record, handler, callback);
},
};
} else if (!process.env.NO_EXT_MONITOR) {
console.log('No newrelic config found here: ' + newrelicFile);
}
module.exports = {
init: function() {},
recordMetric: function() {},
noticeError: function() {},
endTransaction: function() {},
createWebTransaction: function(url, handle) {
return handle();
},
createBackgroundTransaction: function(name, group, handle) {
return handle();
},
addCustomParameter: function(name, value) {},
recordCustomEvent: function(name, value) {},
getTransaction: function() {},
startSegment: function(name, record, handler, callback) {
return handler();
},
};