opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

Marshal log record as JSON

Open corentinmusard opened this issue 1 year ago • 1 comments

Problem Statement

I want to write log record to a file in JSON format, is there any way to do it?

I saw in https://github.com/open-telemetry/opentelemetry-go/pull/5172#discussion_r1555020640 that this feature has been postponed.

Proposed Solution

Export this method: func (e *Exporter) newRecordJSON(r sdklog.Record) recordJSON

corentinmusard avatar Jun 10 '24 08:06 corentinmusard

This is not a stable JSON representation. See https://pkg.go.dev/go.opentelemetry.io/otel/exporters/stdout/stdoutlog#pkg-overview:

it does not provide an interchange format for OpenTelemetry that is supported with any stability or compatibility guarantees

However, it is possible we could provide such functionality as part of otlplogfile package. Reference:

  • https://github.com/open-telemetry/opentelemetry-go/issues/5408

pellared avatar Jul 31 '24 12:07 pellared