elastic / elastic/apm-agent-nodejs

elastic-apm-node does not send express transactions

Open
#1,825 0 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

`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:
![image](https://user-images.githubusercontent.com/25006376/94918736-7431a600-04b3-11eb-847b-d6ecb9444c0f.png)

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.