Class OtlpLogExporter

java.lang.Object
codes.grow.packages.otelcollector.OtlpLogExporter
All Implemented Interfaces:
LogExporter

public final class OtlpLogExporter extends Object implements LogExporter
LogExporter (SPEC section 4) that sends records to the collector over OTLP with the official OpenTelemetry log exporter: POST {logsUrl} (application/x-protobuf) or gRPC LogsService/Export. Retries (HTTP 429/502/503/504, retryable gRPC codes) are done by the exporter within OtelCollectorConfig.exportTimeout(). A partial success reports rejected with a ValidationException.

Exports run one at a time (the outcome of each request is read from the exporter's sender).

  • Field Details

    • SCOPE

      public static final io.opentelemetry.sdk.common.InstrumentationScopeInfo SCOPE
      Instrumentation scope of records exported by this class.
  • Constructor Details

    • OtlpLogExporter

      public OtlpLogExporter(OtelCollectorConfig config)
      Creates an exporter.
      Parameters:
      config - collector config (endpoint, protocol, headers, compression, TLS, timeout)
  • Method Details

    • endpoint

      public String endpoint()
      Returns the endpoint records are sent to (logsUrl for HTTP, grpcUrl for gRPC).
      Returns:
      the endpoint
    • officialExporter

      public static io.opentelemetry.sdk.logs.export.LogRecordExporter officialExporter(OtelCollectorConfig config, boolean gzip)
      Builds the official OTLP log record exporter for a collector config (also used for the LoggerProvider of initTelemetry).
      Parameters:
      config - collector config
      gzip - whether to compress (only when the config compression is gzip)
      Returns:
      the exporter
    • export

      public CompletableFuture<ExportResult> export(List<LogRecord> records, ExportOptions options)
      Exports records in one OTLP request. The future never fails: failures are reported in ExportResult.error() with every record counted as rejected.
      Specified by:
      export in interface LogExporter
      Parameters:
      records - records
      options - gzip and deadline
      Returns:
      the result
    • shutdown

      public CompletableFuture<Void> shutdown()
      Waits for in-flight exports and releases connections. Idempotent.
      Specified by:
      shutdown in interface LogExporter
      Returns:
      a future completed when shut down