Skip to content

Namespaced Attributes for Pino and Consola Integrations #18605

Description

@s1gr1d

Problem

Currently, when logging objects with Pino and Consola, object properties are extracted as top-level attributes, making it unclear where they originate from:

Current behavior:

// Pinopino.info({user: 'user-id',something: {more: 3}});// Results in:
attributes: {'pino.logger.level': {value: 30,type: 'integer'},// object keys added as top-level attributesuser: {value: 'user-id',type: 'string'},something: {value: '{"more":3}',type: 'string'},}

Right now, the Consola integration only stringifies the values and doesn't add them as attribute but there is a PR for that: #18602

But while working on this PR, I discovered that adding the object keys as top-level attributes might not work well as this log would result like this in Sentry:

consola.info("Mixed data",{userId: 123,nestedMetadata: {id: 789,name: "Jane",source: "api"}},newDate("2023-06-15T12:00:00.000Z"))
Image

Proposed Solution

Use namespaced attributes to make the origin clear:

  • consola.args.0, pino.args.0 → for args without keys (arrays, dates, etc.)
  • consola.args.userId, pino.args.userId → for object properties
  • The body could be Mixed data [object] [date]

This would:

  1. Make it clear which attributes come from logged arguments
  2. Prevent potential conflicts with system/integration attributes
  3. Provide consistent behavior between Pino and Consola integrations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions