elastic / elastic/apm-agent-nodejs
isStarted() returns true even if agent is not active
- 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
Assessment
This issue has not been assessed yet.