apm-agent-nodejs icon indicating copy to clipboard operation
apm-agent-nodejs copied to clipboard

"active" config not being respected when the agent is started with -r or top level import

Open csnate opened this issue 8 months ago • 1 comments

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:

  1. Use this config elastic-apm-node.js
module.exports = {
  active: false,
  serverUrl: "https://apm.my-server.com",
  serviceName: "my-service"
  environment: "development"
};
  1. Then call node -r elastic-apm-node/start.js app.js
  2. Then do some actions that would send data to Elastic APM
  3. 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"

csnate avatar Jun 28 '24 19:06 csnate