@Javier_Aracil Ah ha! That's just the information we needed. Here's what's going on.
When the agent encounters the following route name
path: '/{identifier}',
it uses HAPI's fingerprint
property to identify the route. With fingerprinting, route paramaters are replaced with ?
. That means path: '/{identifier}',
is represented as /?
. A route named path: '/{identifier1}/foo/{identifier1}',
would be represented as path: '/?/foo/?',
, etc. It's how HAPI wants these routes to be identified -- if HAPI changes how fingerprinting works, the agent will pickup that new behavior automatically.
Based on what you've said so far, it sounds like you want your routes named based on the identifier
parameter. This is where setTransactionName
can help. If you try something like this
server.route({
method: 'GET',
path: '/{identifier}',
handler: (request, h) => {
const identifier = request.params.identifier
apm.setTransactionName('GET /{identifier}')
return `Hello ${identifier}`;
}
});
you'll have every request grouped under a single transaction (same behavior as now), but named in a way that makes it more explicit which route they're coming from.
Or, if you want to break things out by the identifier, you could try something like this.
server.route({
method: 'GET',
path: '/{identifier}',
handler: (request, h) => {
const identifier = request.params.identifier
apm.setTransactionName(`GET ${identifier}`)
return `Hello ${identifier}`;
}
});
Here we're using the value of identifier
to name the transaction. You'll want to be careful with this -- if you have many hundreds or thousands of different identifiers you might overwhelm the user interface and cause a naming explosion -- but if you have a limited number of identifiers it sounds like this will get you where you need to go.