forked from elastic/apm-agent-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
29 lines (24 loc) · 778 Bytes
/
start.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
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/
'use strict';
// Load and start the APM agent.
//
// Note: Currently this will *not* start the agent in Worker threads because
// that is arguably not desired default behavior when using:
// node --require=elastic-apm-node/start.js ...
const apm = require('./');
var isMainThread;
try {
var workerThreads = require('worker_threads');
isMainThread = workerThreads.isMainThread;
} catch (_importErr) {
// worker_threads were added in node 12 and behind a flag in node ^10.5.0.
isMainThread = true;
}
if (isMainThread) {
apm.start();
}
module.exports = apm;