datadog

Datadog how to join RUM events with logs


I know datadog RUM collects a series of events within a session, and datadog log collection can also group logs within a session. In my app, I initialize the RUM and log collection separately. I want to associate logs with RUM events within the same session. I see both RUM and log collection expose session_id. Will they generate the same session_id for the same session? If not what data can I use to join those 2 records?

I currently have these 2 blocks of code to initialize logs and RUM

datadogLogs.init({
  clientToken: '<DATADOG_CLIENT_TOKEN>',
  site: '<DATADOG_SITE>',
  forwardErrorsToLogs: true,
  sessionSampleRate: 100,
});


datadogRum.init({
  applicationId: '<DATADOG_APPLICATION_ID>',
  clientToken: '<DATADOG_CLIENT_TOKEN>',
  site: '<DATADOG_SITE>',
  sessionSampleRate: 100,
  sessionReplaySampleRate: 100,
  trackResources: true,
  trackLongTasks: true,
  trackUserInteractions: true,
  enablePrivacyForActionName: true,
});

Solution

  • Assuming you are referring to browser logs, RUM events and logs are automatically correlated. This requires that your browser SDK and RUM configurations are matching. The session ids will match across logs and RUM events.