Class OtlpJsonEncoder

All Implemented Interfaces:
LogEncoder

Encodes each event as one line of OTLP/JSON: a complete LogsData object holding a single log record. This is the OpenTelemetry file format, read by the OpenTelemetry Collector's otlpjsonfile receiver or by the filelog receiver with the otlpjson connector, so it needs no network connection.

Each record carries the formatted message as its body, the logger name as its instrumentation scope, thread.name, thread.id, the key values selected by keyValuesIncluded and keyValuesExcluded (all by default), and for a throwable exception.type, exception.message, and exception.stacktrace attributes. When the event has caller info it also carries code.function.name, code.file.path, and code.line.number. Event thread, caller, and exception attributes take precedence over key values with the same names. Key values named by traceIdKey and spanIdKey (default traceId and spanId, as Micrometer Tracing puts them in the MDC) become the record's trace context when they are valid W3C ids, and the key value otel.event.name becomes the record's event name.

The include and exclude lists are case sensitive globs where * matches any characters and ? matches one character. An excluded key is never added.