Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Double slash preprended to route names

nodeagent

#1

I’m currently using custom instrumentation to track my api calls:

newrelic.startWebTransaction('get api/v1/people');

For some reason it keeps adding // to the beginning of the names in newrelic, for example:

//get api/v1/people

How do I remove those two slashes?


#2

Hey there @epsilon812-

Thanks for writing to the community! Hmm, you’re right that this behavior is not expected… Looking at the example API call you provided, it looks like you’re missing some required params. Here’s a link for our documentation on this call where you can read about the url and handle params for this call:

https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/nodejs-agent-api

I’d also like the highlight the last paragraph from the section on the startWebTransaction call. Are you also using newrelic.getTransaction() and transaction.end() as detailed in the docs?

Let me know the outcome up updating the API call with the params. I hope this info helps!

Cheers!

–Sara


#3

Oh sorry. I’ll post a more complete example of what I am doing.

I’m using Primus which is a WebSocket library. I have access to the events for incoming and outgoing data. However, I can’t call transaction.end() inside of the context of the transaction. I’m not sure, but this may be causing issues?

primus.on('connection', spark => {
  const transactions = {};

  spark.on('incoming::data', request => {
    // id is a number, for example 1
    // Url is a route of the format, api/v1/people, for example.
    const { url, id, method } = getRequestParts(request);
    if (isNil(url) || isNil(id) || !isSupportedMethod(method)) {
      return;
    }
    newrelic.startWebTransaction(`${url}`, () => {
      transactions[id] = newrelic.getTransaction();
    });
  });

  spark.on('outgoing::data', request => {
    const { id } = getRequestParts(request);
    if (isNil(id)) {
      return;
    }
    const transaction = transactions[id];
    if (transaction) {
      transaction.end();
      delete transactions[id];
    }
  });
});

Thanks!


#4

Hi there!

I followed up with our engineering team on this and we’d like to suggest that you try removing the “get” in your call. It would look something like this:

newrelic.startWebTransaction('api/v1/people');

If this doesn’t resolve the issue, could you follow up with sending us a permalink to the application we’ve been troubleshooting?

I hope this information helps. Thanks!

–Sara