elastic / elastic/apm-agent-nodejs
elastic-apm-node does not send express transactions
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
`elastic-apm-node` does not send any transaction when the server receives http requests.
**To Reproduce**
```js
// Initializes apm client
const apm = require('elastic-apm-node').start({
serviceName: 'myApp',
serverUrl: 'http://localhost:8200',
environment: 'dev',
logLevel: 'trace',
});
// Sends a transaction manually with random values **Correctly received by APM as a transaction (see image below)**
apm.startTransaction('test', 'type', 'subtype', 'action', { startTime: new Date().valueOf() }).end('success', '1000');
// Initializes express
const app = express();
// Imports my routes (ex: POST /auth/login)
require('./app/routes/routes')(app, passport, version, guard);
app.listen(3000);
```
When I use `POST /auth/login`, the http request is not sent by `elastic-apm-node` (there is no trace log for this transaction).
> Note: APM server correctly receives metrics
> Note: When I start a new project with this [configuration](https://www.elastic.co/guide/en/apm/agent/nodejs/master/express.html#express-initialization), it works perfectly.
**Expected behavior**
APM agent must sends a transaction when a HTTP request is received on the Express server.
**Environment**
- OS: MacOS Catalina 10.15.3
- Node.js version: v14.12.0
- APM Server version: 7.4.0
- Agent version: 3.3.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**
- `package.json` dependencies:
Click to expand
```
"elastic-apm-node": "^3.3.0",
"elasticsearch": "^16.3.0", // used with [winston](https://www.npmjs.com/package/winston-elasticsearch)
"express": "^4.17.1",
```
- Result of my manual transaction:

Contributor guide
Assessment
This issue has not been assessed yet.