apm-agent-rum-js
apm-agent-rum-js copied to clipboard
Spans in custom transactions missing names
Hi, We are creating custom transactions and custom spans within it like in the minimal example below.
But when you look at the logs on kibana, the names of the spans are missing.
Is there something we are doing wrong? or is this a bug?
We are using "@elastic/apm-rum-angular": "version": "2.0.1" on chrome.
@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?
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;
});
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
.
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'
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.