Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call setGlobalLabel causes exception when apm is not activated #3442

Closed
1 of 3 tasks
binsee opened this issue Jun 26, 2023 · 0 comments · Fixed by #3443
Closed
1 of 3 tasks

call setGlobalLabel causes exception when apm is not activated #3442

binsee opened this issue Jun 26, 2023 · 0 comments · Fixed by #3443
Assignees
Labels
agent-nodejs Make available for APM Agents project planning. bug community

Comments

@binsee
Copy link
Contributor

binsee commented Jun 26, 2023

Describe the bug

When starting with { active: false}, calling setGlobalLabel triggers an exception: TypeError: Cannot read properties of null (reading 'config')

To Reproduce

Steps to reproduce the behavior:

  1. Use this config '{ active: false}'
  2. Then call 'setGlobalLabel'
  3. See error:
/Users/binsee/CodeWork/test/node_modules/elastic-apm-node/lib/agent.js:368
   this._apmClient.config({
                   ^
TypeError: Cannot read properties of null (reading 'config')
     at Agent.setGlobalLabel (/Users/binsee/CodeWork/test/node_modules/elastic-apm-node/lib/agent.js:368:19)
     at Object.<anonymous> (/Users/binsee/CodeWork/test/src/1.ts:4:5)

Expected behavior

Regardless of whether it is active or not, no error should be reported

Environment (please complete the following information)

  • OS: MacOS
  • Node.js version: 16.19.0
  • APM Server version: ``
  • Agent version: 3.47.0

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

Agent config options:

Click to expand
{ active: false }

package.json dependencies:

Click to expand
   "elastic-apm-node": "^3.47.0",

Test code:

Click to expand
import apm from 'elastic-apm-node'

apm. start({ active: false })
apm.setGlobalLabel('token', 'test-01')

setTimeout(() => {
   console. log('hello')
}, 5000)
@github-actions github-actions bot added agent-nodejs Make available for APM Agents project planning. community triage labels Jun 26, 2023
@binsee binsee changed the title Cannot read properties of null (reading 'config') when call setGlobalLabel causes exception when apm is not activated Jun 26, 2023
binsee added a commit to binsee/apm-agent-nodejs that referenced this issue Jun 26, 2023
binsee added a commit to binsee/apm-agent-nodejs that referenced this issue Jun 26, 2023
@trentm trentm self-assigned this Jun 27, 2023
@trentm trentm added bug and removed triage labels Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning. bug community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants