-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
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:
// Pino
pino.info({ user: 'user-id', something: { more: 3 } });
// Results in:
attributes: {
'pino.logger.level': { value: 30, type: 'integer' },
// object keys added as top-level attributes
user: { 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" } },
new Date("2023-06-15T12:00:00.000Z")
)
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:
- Make it clear which attributes come from logged arguments
- Prevent potential conflicts with system/integration attributes
- Provide consistent behavior between Pino and Consola integrations
Metadata
Metadata
Assignees
Labels
No labels