You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The active config value is not being respected when it's set to "false" if I start the agent with the require start module or the -r opt and I use the agent config file to load the configuration. All of the other options are correctly being used (data is getting to the apm server, service name and environment are set, etc.) but if I set active: false, Elastic APM is still recording data.
If I use the require and start way to start the agent, then it looks like the active flag is working as expected.
Before this line 862 the options are read in from the file, so fileOpts['active'] = false;
Line 879, the check isn't going to pass because fileOpts[def.name] would evaluate to false, and then def.fileValue does not get set to false
Then when the Config is constructed, the default value for active will "win out" since it is set and the fileOpts.active value is not set.
Also, the reason it DOES work when passing the config into apm.start({...}) is because that config object gets assigned to Config after the defaults, so the value would be active: false correctly.
The fix would be to change that check on line 879 to be typeof fileOpts[def.name] !== "undefined". Wouldn't hurt to do the same thing on line 876 in case an environment variable was set to false as well.
If I get some time next week I can fork and submit a PR
csnate
pushed a commit
to csnate/apm-agent-nodejs
that referenced
this issue
Jul 1, 2024
This allows a "false" boolean value to override a "true" default value when loading the options via the elastic-apm-node.js config file
Fixes: elastic#4112Closes: elastic#4112
This allows a "false" boolean value to override a "true" default value when loading the options via the elastic-apm-node.js config file
Fixes: elastic#4112Closes: elastic#4112
Describe the bug
The active config value is not being respected when it's set to "false" if I start the agent with the require start module or the -r opt and I use the agent config file to load the configuration. All of the other options are correctly being used (data is getting to the apm server, service name and environment are set, etc.) but if I set
active: false
, Elastic APM is still recording data.If I use the require and start way to start the agent, then it looks like the
active
flag is working as expected.To Reproduce
Steps to reproduce the behavior:
elastic-apm-node.js
node -r elastic-apm-node/start.js app.js
Expected behavior
No data is sent to Elastic APM when
active: false
when started with "require start module" or "-r opt"Environment (please complete the following information)
How are you starting the agent? (please tick one of the boxes)
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
)elastic-apm-node/start
from within the source code-r elastic-apm-node/start
Additional context
Agent config options:
Click to expand
package.json
dependencies:Click to expand
The text was updated successfully, but these errors were encountered: