Open isikhi opened 1 year ago
I tried with different version of apm (3.x , 4.x) and the results are same.
Hi @isikhi
Thanks for giving implementation details for the issue, it is really helpful :)
From your example we noticed express
is required before agent starts. In that specific case we cannot guarantee the correct instrumentation of the module.
I've placed the agent start at the top and run the code again
require('elastic-apm-node').start({
// config here...
);
const express = require('express');
const logger = require('morgan');
const app = express();
// ...rest of the code
The result is what I think you're expecting. Transaction has the path in their name (as shown in the following screenshot)
Could you confirm that this fixes the issue?
Cheers
I will directly simplify this problem with sample code.
Once I delved into the code a bit I simplified it to this level.
I also reviewed instrumentation here. It looks inside the request object in the Express Route, but if there is a route in the form of Express.Use (which may not be the best practice, but Express performs all route operations related to it without any problems.) Then, if a response is returned in any of the middleware except the last one, APM cannot capture the transaction name there. It appears as an unnamed transaction - unknown route.
As you can see kibana logs here:
And the source code which you can reproduce. I may contribute it
app.js
www
package.json