forked from Meteor-Community-Packages/meteor-elastic-apm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeteor-elastic-apm.js
41 lines (33 loc) · 997 Bytes
/
meteor-elastic-apm.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
const Agent = require("elastic-apm-node");
const errors = require('./hijack/errors');
const http = require('./hijack/http');
const session = require('./hijack/session');
const subscription = require('./hijack/subscription');
// whoops `async` name is reserved
const asyncH = require('./hijack/async');
const db = require('./hijack/db');
// this is where our wrap code starts
const startAgent = Agent.start;
Agent.start = function(config){
config = config || {};
if(config.active !== false){
MeteorX.onReady(() => {
session(Agent);
subscription(Agent);
errors(Agent);
asyncH(Agent);
db(Agent);
http(Agent);
try {
startAgent.apply(Agent, [config]);
console.log("meteor-elastic-apm completed instrumenting");
} catch(e){
console.error("Could not start meteor-elastic-apm");
console.error(e);
}
});
} else {
console.warn("meteor-elastic-apm is not active");
}
};
module.exports = Agent;