Add custom Information for correlation using JavaScript agent (RUM)

Hi,

we have the JavaScript agent (RUM) in place and are also collecting the logs via filebeat.
In order to be able to correlate the data between RUM and the Logs I would like to add some custom information on the client via the JS agent, e.g. the session id from a cookie.
Is this possible? How? Unfortunately I did not find any useful information so far...
I just found the possibility to correlate APM data and logs via trace ids using the Java agent, but I would like to correlate on an existing information e.g. session id from the application, which is already in the logs.

Thanks in advance for any help!

ciao

Hi @fuphil

Thanks for reaching out!

There is a way to add custom metadata on all transaction, error and span events:

elasticApm.init({
   serviceName: 'your-service-name',
   serverUrl: 'https://yourAPMendpoint/'
})
// Set metadata on all transaction, error and span events
elasticApm.addLabels({
  label1: 'value1',
  label2: 'value2'
})

More info here

On the other hand, you can also add labels to specific transactions and spans as you can see in the transaction API documentation and span API documentation

In the JavaScript agent we have also available distributed tracing, specific documentation for JavaScript agent here

Important to take into account that in the case of RUM the trace data are only appended to API calls (fetch/xhr). If you want to trace the HTML document generation, you would have to set up the RUM agent with appropriate page-load trace details.

Hope this helps you

Thanks,
Alberto

Thank you very much, I will try it with the lables!

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