Transaction table breakdown granularity

Hello everyone,

I am a newbie to Elastic APM, I am currently trying to instrument a great banking application (javascript).

In the transaction table I get many URLs of the type POST http: //<server IP>/method summarized in a single line POST /? .

What can I do to get better granularity in the breakdown of the transaction table?

Thank you very much,

Javier

Hey @Javier_Aracil
Welcome to the Community.

Can you check what you see in the Metadata tab? Is there a more useful request name available for you?
I guess you are using the RUM agent right?
The data you see highly depends on the JS Framework you are using. Thatswhy we need to check that first.

Hi Felix,

Thanks, we actually see the transactions in the Metadata tab

No, not RUM, actually the nodejs agent

Framework is hapi.

Thanks a lot for your help,

Javier

Perhaps this can do the trick?
Thanks

Yes thats the why I was asking

Hi Felix, it didn´t work, any idea? Thanks

Javier

Hello @Javier_Aracil, it's nice to meet you.

Two things.

First -- you mentioned you're using hapi. When you use hapi with the Node.js agent we'll automatically name the transaction based on the route naming pattern/path. If you can share that, and share the version of hapi that you're using, we'll be better able to diagnose why all your transactions end up with the same POST /? name.

Second -- we know that sometimes the default naming of a transaction doesn't meet everyone's needs. Because of that, the agent has an API method that allows you to name a transaction. The apm.setTransactionName(...) method should allow you to name your own transactions with whatever names you like -- just call this method at the start of your hapi route handling method.

If that gets you fixed up, great. If not, then just share some code (either real or fake) with an example of how you're using hapi to define your routes and what let us know what version of hapi you're using. With that information in hand we'll be better able to diagnose your issue.

Hi @alanstorm ,

I examined the js code and it turns out that routes are declared as follows:

server.route({
    method: 'GET',
    path: '/{identifier}',
    handler: (request, h) => {
        const the_identifier = request.params.identifier
        return `Path ${the_identifier}`;
    }
});

Then, transactions end up with GET /?, namely:

hapi version is 20.1.2

Any workaround that we can apply for this? Thanks so much,

Javier

@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.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.