Class BetterStackOtlpLogExporter

java.lang.Object
codes.grow.packages.betterstack.BetterStackOtlpLogExporter
All Implemented Interfaces:
LogExporter

public final class BetterStackOtlpLogExporter extends Object implements LogExporter
LogExporter that sends OTLP/HTTP logs to the source's ingesting host (POST {url}/v1/logs, Authorization: Bearer <source token>), protobuf by default or OTLP/JSON.

Records are grouped by resource; batches are split so that no request exceeds maxRequestBytes. A partial_success answer counts its records as rejected. Exports are retried like idempotent calls (duplicates are possible after an ambiguous failure). Get one from BetterStackClient.otlpExporter().

  • Field Details

  • Method Details

    • protocol

      public OtlpProtocol protocol()
      Returns the payload format.
      Returns:
      the protocol
    • scopeName

      public String scopeName()
      Returns the instrumentation scope name.
      Returns:
      the name
    • encode

      public byte[] encode(List<LogRecord> records)
      Encodes records as one request body (protobuf bytes or OTLP/JSON text).
      Parameters:
      records - records
      Returns:
      the body
    • export

      public CompletableFuture<ExportResult> export(List<LogRecord> records, ExportOptions options)
      Sends the records; the future never fails for service errors (see LogExporter).
      Specified by:
      export in interface LogExporter
      Parameters:
      records - records
      options - gzip flag and time budget
      Returns:
      the result
    • send

      public Optional<OtlpLogs.PartialSuccess> send(List<LogRecord> records, boolean gzip)
      Posts one OTLP request for records (no splitting).
      Parameters:
      records - records
      gzip - gzip-compress the body
      Returns:
      the partial success when the service reports rejected records
      Throws:
      BetterStackException - mapped like the ingest API (403 authentication, 402 quota)
    • sendAsync

      public CompletableFuture<Optional<OtlpLogs.PartialSuccess>> sendAsync(List<LogRecord> records, boolean gzip)
      Asynchronous send(List, boolean).
      Parameters:
      records - records
      gzip - gzip-compress the body
      Returns:
      a future with the partial success, if any
    • shutdown

      public CompletableFuture<Void> shutdown()
      Nothing to release; the client owns the transport.
      Specified by:
      shutdown in interface LogExporter
      Returns:
      a completed future