Class OtlpOutput

java.lang.Object
io.jstach.rainbowgum.otlp.OtlpOutput
All Implemented Interfaces:
LogLifecycle, LogOutput, LogOutput.ProvidesEncoder, Flushable, AutoCloseable

public final class OtlpOutput extends Object implements LogOutput, LogOutput.ProvidesEncoder
Sends log events to an OTLP/HTTP endpoint (/v1/logs) as protobuf (the default) or JSON, without the OpenTelemetry SDK or a protobuf library.

Events are buffered and sent as one request per flush(), and as soon as maxBatchSize events are pending. Use an asynchronous publisher: with the default synchronous one every log call waits for its own HTTP request. HTTP 429, 502, 503, and 504 responses and network errors are retried up to three times with exponential backoff with jitter, honoring Retry-After. The timeout bounds the whole export, including retries and response-body reads. A batch that still fails is dropped, recorded as an error alert, and counted in "otlp.records.failed". Records the endpoint reports as rejected (partial success) are a warning alert and counted in "otlp.records.rejected".

The endpoint is trusted with the log records but not with the application: at most 64 KiB of a response is read, text from it is escaped and shortened before it is put in an alert, and redirects are not followed, as they would send the request headers elsewhere.

This output encodes events itself, so it does not use an appender encoder. Records have the same content as OtlpJsonEncoder produces.