Skip to content

Commit

Permalink
Ensure APM agent config file path respects CWD
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Dec 12, 2019
1 parent 989a349 commit 1af7980
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/apm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ module.exports = function (serviceName = name) {
if (process.env.kbnWorkerType === 'optmzr') return;

const conf = {
serviceName: `${serviceName}-${version.replace(/\./g, '_')}`
serviceName: `${serviceName}-${version.replace(/\./g, '_')}`,
};

if (configFileExists()) conf.configFile = 'config/apm.js';
const configFile = join(__dirname, '..', 'config', 'apm.js');

if (existsSync(configFile)) conf.configFile = configFile;
else conf.active = false;

require('elastic-apm-node').start(conf);
};

function configFileExists() {
return existsSync(join(__dirname, '..', 'config', 'apm.js'));
}

0 comments on commit 1af7980

Please sign in to comment.