Skip to content

Feathersjs 5 unknowk traces #4979

@ramzes13

Description

@ramzes13

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:

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.

const httpMethods: Record<string, string> = {
  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}`);
}
"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"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions