elastic / elastic/apm-agent-nodejs
Incorrect transaction name if an array of patterns is passed to app.use()
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
**Describe the bug**
Passing app.use() an array of patterns instead of a single value causes transaction.name to be set incorrectly.
**To Reproduce**
This works as expected (the transaction name is "GET /foo"):
```
require('elastic-apm-node').start({
serverUrl: 'http://localhost:8200',
});
const app = require('express')();
app.use('/foo', (req, res) => res.sendStatus(200));
app.use('/bar', (req, res) => res.sendStatus(200));
app.listen(8888);
// curl -s localhost:8888/foo
```
This doesn't (the transaction name is set to "GET unknown route"):
```
require('elastic-apm-node').start({
serverUrl: 'http://localhost:8200',
});
const app = require('express')();
app.use(['/foo', '/bar'], (req, res) => res.sendStatus(200));
app.listen(8888);
// curl -s localhost:8888/foo
```
**Expected behavior**
The transaction name should be set correctly.
**Environment (please complete the following information)**
- Node.js version: 10.16.3
- APM Server version: 7.4.0
- Agent version: 3.1.0
**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.