getsentry/sentry-javascript

Attributes not added to logs sent via consoleLoggingIntegration

Closed this issue · 2 comments

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

10.13.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
  dsn:"...", /
  integrations: [
    Sentry.consoleLoggingIntegration({ levels: ["debug"] }),
  ],
});

//consts
        const topic = "logs"
        const status = "ok"
        const supabaseError = "supabaseError"

//write log        
console.debug('Console debug log', {
        time: new Date().toISOString(),
        topic: topic,
        status: status,
        error: supabaseError,
        });

//send log to Sentry
        Sentry.logger.error('Sentry logger log', {
        time: new Date().toISOString(),
        topic: topic,
        status: status,
        error: supabaseError,

Steps to Reproduce

  1. run a script like the above
  2. go to Explore -> Logs

Expected Result

The attributes set in the console.debug are individually added and can be used to filter logs, like the attributes added to the Sentry.logger call:

Image

Actual Result

Logs are reported under "parameter.0" and grouped together, making it not possible to search by them individually.

Image

Additional Context

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Logs are reported under "parameter.0" and grouped together, making it not possible to search by them individually.

Yes this is intended behaviour, we do not unfurl the the json client-side. If we did, we'd have duplicates in the payload, as console.X would output the entire thing in the log message, and then you'd get it also in attributes.

To get around this for now, you can use the Sentry logger APIs, or wait till we automatically unfurl json in attributes (tracked in this issue getsentry/sentry#98042)