elastic / elastic/apm-agent-nodejs

isStarted() returns true even if agent is not active

Open
#1,109 8 comments 0 reactions 0 assignees View on GitHub
agent-nodejs
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

**Describe the bug**
isStarted() returns true even if agent is not active

**To Reproduce**
Steps to reproduce the behavior:
```javascript
const apm = require('elastic-apm-node').start({ active: false, ...});
if (apm.isStarted()) {
apm.captureError(new Error(), err => console.error(err));
}
```
Error logged: `Error: cannot capture error before agent is started`

**Expected behavior**
Expect to use isStarted() as a guard to run `captureError` method

**Environment (please complete the following information)**
- OS: mac-os
- Node.js version: v8.11.2
- Agent version: lastic-apm-node@2.11.5

**How are you starting the agent? (please tick one of the boxes)**
- [x] 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`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.