-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinit.js
More file actions
33 lines (29 loc) · 1.27 KB
/
init.js
File metadata and controls
33 lines (29 loc) · 1.27 KB
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
var config = require('./lib/config'),
debugOffline = require('./offline_debug'),
logger = require('./lib/logger'),
_instruments = require('./lib/instruments.js');
// initialization code, run once when module is loaded
debugOffline(); // override module load handler
// this timer is used to ensure that first-time configuration load
// is perfromed in some delay (1 sec) after the rest of the code
// is loaded, to avoid issues with cicular dependencies
var waitForConfigReload = setInterval(function () {
if (config.status === "done") {
// after first-time configuraiton load, the responsibility
// for subsequent loads is moved to the initIntervaling
// function in config.js
logger.info('Instrumentation configuration is loaded');
config.initIntervaling();
// clear the current timer
clearInterval(waitForConfigReload);
} else if (config.status === "init") {
// if we got here it means the configuration has not loaded yet
// init the first-time configuration load
config.reload();
// the time is still running, next iteration will be either 'loading'
// or 'done'
}
}, 1000);
// end initilization
// export the helper functions so that instrumented code can report events
module.exports = _instruments;