apm-agent-nodejs
apm-agent-nodejs copied to clipboard
"active" config not being respected when the agent is started with -r or top level import
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:
- Use this config elastic-apm-node.js
module.exports = {
active: false,
serverUrl: "https://apm.my-server.com",
serviceName: "my-service"
environment: "development"
};
- Then call
node -r elastic-apm-node/start.js app.js
- Then do some actions that would send data to Elastic APM
- See that data is still getting reported to Elastic APM
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)
- OS: Linux Alpine/Docker
- Node.js version: 20.15.0
- APM Server version: 8.10.2
- Agent version: 4.7.0 or 8.10.2 if you mean the Elastic Server Agent?
How are you starting the agent? (please tick one of the boxes)
- [ ] Calling
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
) - [X] Requiring
elastic-apm-node/start
from within the source code - [X] Starting node with
-r elastic-apm-node/start
Additional context
Agent config options:
Click to expand
{
active: false,
serverUrl: "https://apm.my-server.com",
serviceName: "my-service"
environment: "development"
}
package.json
dependencies:
Click to expand
"elastic-apm-node": "4.7.0"