apm-agent-nodejs: Transaction name is `${method} unknown route` in Koa

Describe the bug Kibana APM UI shows all transaction name as ${method} unknown route. I think it should be ${method} ${path}. How should I fix?

To Reproduce Steps to reproduce the behavior: No configuration. Imported on the top of main script file.

Expected behavior I think it should be ${method} ${path}.

Environment (please complete the following information)

  • OS: Ubuntu 16.04 LTS
  • Node.js version: 10.15.0
  • APM Server version: 6.5.4
  • Agent version: 2.1.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 Add any other context about the problem here.

  • Agent config options

    Click to expand
    replace this line with your agent config options
    
  • package.json dependencies:

    Click to expand
    replace this line with your dependencies section from package.json
    

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

@sibelius the require-in-the-middle module uses the debug module for outputting debug info. So if you use the environment variable DEBUG you can get it to output debug information:

DEBUG=require-in-the-middle

Ah, I figured it out! I’m now able to recreate this locally.

In a temp directory, you can recreated it by doing the following:

mkdir node_modules
npm install koa-router watson/apm-agent-nodejs#debug2
cp -r node_modules tmp-node_modules
mv tmp-node_modules node_modules/node_modules
DEBUG=* node test.js

Where test.js contains the following:

require('elastic-apm-node').start({serviceName: 'test'})
require('koa-router')

This will nest the node_modules folder inside it self which will trip up our algorithm.