Skip to content

pino logged instrumentation mapping of the log record into body and attributesΒ #3012

@segevfiner

Description

@segevfiner
  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first

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. Learn more here.

The current instrumentation for the Pino logger takes the log record and puts the message string in the body and the rest of it in attributes of the otel log record respectively. Despite this being a structured logger, where the rest of the record can be arbitrary nested JSON.

When I then set up a collector to forward this to Google Cloud for example, body got put as a textPayload, and the rest dumped as labels which are a plain string to string mapping, so nested JSON got serialized, which makes it not very useful for later querying based on those fields

There doesn't seem to be anything obvious on how to handle this in the instrumentation or the exporter.

The body in otel logging can be a JSON object as far as I know for structured loggers, which will allow for such nested fields to be streamed out as jsonPayload into Google Cloud, but there is then a further complication in that Google Cloud expects there to be a key named message in the log payload for the canonical text message of the log, which is something I think otel doesn't specify and I wonder how should this be handled correctly should I also need to integrate other similar loggers from other languages frameworks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions