elastic / elastic/apm-agent-nodejs

Feathersjs 5 unknowk traces

Open
#4,979 0 comments 0 reactions 0 assignees View on GitHub
community triage
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

**Describe the bug**

After upgrading from FeathersJS v4 to FeathersJS v5, all HTTP transaction names in APM are reported as GET unknown route (or similar HTTP method variants) instead of the actual service paths (e.g., GET /my-service).

As a workaround we call apm.setTransactionName() inside a Feathers before:all app hook.

**To Reproduce**

Create a FeathersJS v5 app using @feathersjs/express (v5.0.35)
Start the APM agent via apm.start() before the app is created
Register a Feathers service at a path (e.g., /reports)
Make an HTTP GET request to that service endpoint
Observe that the transaction name in APM shows GET unknown route instead of GET /reports
Expected behavior

Transaction names should reflect the actual matched Express route, as they did with FeathersJS v4. Expected: GET /reports, Actual: GET unknown route.

**Environment**

OS: Ubuntu 25.04
Node.js version: v20.18.1
APM Server version: 9.3.0
Agent version: 4.15.0

**How are you starting the agent?**

Calling agent.start() directly (e.g. require('elastic-apm-node').start(...))
The agent is started inside a wrapper class before the Feathers app is created:

```js
import apm from 'elastic-apm-node';

this.apm = apm.start({
serviceName: process.env.ELASTIC_APM_SERVICE_NAME,
secretToken: process.env.ELASTIC_APM_SECRET_TOKEN,
serverUrl: process.env.ELASTIC_APM_SERVER_URL,
environment: process.env.ELASTIC_APM_ENVIRONMENT,
});
```
**Additional context**

We also apply a before:all app hook to manually set the transaction name as a workaround.

```js
const httpMethods: Record = {
find: 'GET',
get: 'GET',
create: 'POST',
update: 'PUT',
patch: 'PATCH',
remove: 'DELETE',
};

function setApmTransactionName(hook: HookContext): void {
if (!eapm.instance || !hook.path) return;
const httpMethod = httpMethods[hook.method] ?? hook.method.toUpperCase();
eapm.instance.setTransactionName(`${httpMethod} ${hook.path}`);
}
```
```js
"dependencies": {
"@feathersjs/configuration": "^5.0.35",
"@feathersjs/errors": "^5.0.35",
"@feathersjs/express": "^5.0.35",
"@feathersjs/feathers": "^5.0.35",
"@feathersjs/transport-commons": "^5.0.35",
"elastic-apm-node": "^4.15.0"
}
```

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.