question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Agent is running before the start function is called.

See original GitHub issue

Describe the bug I have a customised start function (example has been simplified)

'use strict';

const apm = require('elastic-apm-node');

const start = () => {

    if (process.env.ELASTIC_APM_ACTIVE !== 'false') {

        apm.start();

    }

    return apm;

};

module.exports = { start };

I use kubernetes and from what I understand all environment variables have to be strings and should be converted in the app if you want it in a different format (boolean etc).

To get around this I specifically check for process.env.ELASTIC_APM_ACTIVE !== 'false' and don’t call the start method.

The problem is even though the start method isn’t called, apm will still log an error to the server.

logging error 3a397735-9dde-4f45-9b5e-212e88197336 with Elastic APM

To Reproduce Steps to reproduce the behavior:

  1. Create a file that returns APM.
  2. Require the file, but don’t call the start method.
  3. Throw an error, it should be logged to the APM server.

Expected behavior The agent should not start and a log Elastic APM agent is inactive due to configuration should appear during start up.

Environment (please complete the following information)

  • OS: Alpine 3.4
  • Node.js version: v6.11.0
  • APM Server version: 🤷‍♂️ current cloud version
  • Agent version: 1.8.2

How are you starting the agent? (please tick one of the boxes)

  • Calling agent.start() directly (e.g. require('elastic-apm-node').start(...))
  • Requiring elastic-apm-node/start from within the source code
  • Starting node with -r elastic-apm-node/start

Additional context Add any other context about the problem here.

  • Agent config options

    Click to expand
    replace this line with your agent config options
    
  • package.json dependencies:

    Click to expand
    "elastic-apm-node": "1.8.2",
    

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
watsoncommented, Apr 10, 2019

FYI: In the new version of the agent this was simplified/changed so that you now just have to set ELASTIC_APM_LOG_LEVEL=trace in order to log the debug output that we need.

0reactions
watsoncommented, Jun 12, 2019

Closing for now due to lack of activity. If it should be reopened, just leave a comment 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Execution Order of Event Functions - Unity - Manual
Awake : This function is always called before any Start functions and also just after a prefab is instantiated. (If a GameObject is...
Read more >
Agent — Elixir v1.12.3 - HexDocs
Starts an agent linked to the current process with the given function. This is often used to start the agent as part of...
Read more >
Pipeline Syntax - Jenkins
In agents declared within a stage, the options are invoked before entering the ... Run the Pipeline or individual stage this agent is...
Read more >
Jobs in Azure Pipelines and TFS - Microsoft Learn
This YAML file has a job that runs on a Microsoft-hosted agent and outputs ... then you can use a special type of...
Read more >
Agent - The Elixir programming language
We have first defined a setup callback with the help of the setup/1 macro. The setup/1 macro defines a callback that is run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found