apm-agent-rum-js icon indicating copy to clipboard operation
apm-agent-rum-js copied to clipboard

Spans in custom transactions missing names

Open sibijohn72 opened this issue 3 years ago • 6 comments

Hi, We are creating custom transactions and custom spans within it like in the minimal example below. image

But when you look at the logs on kibana, the names of the spans are missing. image

Is there something we are doing wrong? or is this a bug?

sibijohn72 avatar Oct 08 '21 09:10 sibijohn72

We are using "@elastic/apm-rum-angular": "version": "2.0.1" on chrome.

sibijohn72 avatar Oct 08 '21 09:10 sibijohn72

@sibijohn72 I just tested this locally and I can see the span names without any issues. Are you adding any filtering logic to the transaction data before it is being sent to the APM server?

vigneshshanmugam avatar Oct 11 '21 17:10 vigneshshanmugam

only the following. but there is nothing here that should affect spans. Everything is done at the transaction level.

apm.observe('transaction:end', (transaction: any) => {
      const regex = /\d+/g;
      const regexParam = /[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}|\d+/gi;
      if (transaction.type === 'http-request') {
        const [method, url] = transaction.name.split(' ');
        const host = url.match(/https?:\/\/[\w\d.:-]+/)[0];
        const [endpoint, querystring] = url.substr(host.length).split('?');
        transaction.name = method + ' ' + host + endpoint.replace(regexParam, '${PARAM}');
        transaction.addLabels({URL_PARAMS: [querystring].concat(endpoint.match(regex))});
      } else if (transaction.type === 'route-change') {
        const {name} = transaction;
        transaction.name = name.replace(regex, '${PARAM}');
        transaction.addLabels({STATE_PARAMS: name.match(regex)});
      } else if (transaction.type === 'user-interaction') {
        const {name, context: {custom: {classes: classes}}} = transaction;
        const jsClasses = classes?.split(' ').filter(className => className.startsWith('js-')) || [];
        transaction.name = `${name}.${jsClasses.join('.') || classes}`;
      }
      if (!transaction.custom) {
        transaction.custom = {};
      }
      // add more custom fields if needed in the future below.
      transaction.custom.xx= xx;
      transaction.custom.xx= xx;
    });

sibijohn72 avatar Oct 12 '21 08:10 sibijohn72

Interesting. I dont see any problem with the above logic. Just to figure out the problem where the problem lies

  • Could you see the correct span names on the POST request payload to the APM server - /intake/v3/rum/events.

vigneshshanmugam avatar Oct 12 '21 15:10 vigneshshanmugam

image

so the post request body itself is garbled but i could see that the span names are correct at least in the logs we see with logelevel: 'debug'

sibijohn72 avatar Oct 14 '21 13:10 sibijohn72

so the post request body itself is garbled You can check in Firefox or browsers that does not support compression spec.

span names are correct at least in the logs

Hmmm, I am not sure what is going wrong then, I would check the POST request payload and if that has the correct names then the issue might be in the APM server, but we have not seen anyone experiencing the same issue, So would require more details for debugging.

vigneshshanmugam avatar Oct 14 '21 15:10 vigneshshanmugam