Class DatadogLogExporter

java.lang.Object
codes.grow.packages.datadoglogs.DatadogLogExporter
All Implemented Interfaces:
LogExporter

public final class DatadogLogExporter extends Object implements LogExporter
LogExporter for POST {intake}/api/v2/logs (API.md section 5; DECISIONS 4, 7).

Maps records to Datadog JSON, truncates oversized messages, splits batches at 1000 entries / 5 MB, gzips when asked and sends with header DD-API-KEY only (the application key is never sent to the intake). The intake POST is retried like an idempotent call (429, 5xx, network errors; duplicates are possible after an ambiguous failure).

  • Field Details

  • Method Details

    • limits

      public DatadogLogExporter.Limits limits()
      Returns the request limits.
      Returns:
      the limits
    • encode

      Maps and splits records into intake request bodies (no I/O).
      Parameters:
      records - records
      Returns:
      the bodies
    • export

      public CompletableFuture<ExportResult> export(List<LogRecord> records, ExportOptions options)
      Sends the records. Completes with accepted/rejected and the error of the first failing request (later chunks count as rejected); never completes exceptionally for service errors.
      Specified by:
      export in interface LogExporter
      Parameters:
      records - records
      options - gzip flag and timeout
      Returns:
      a future with the result
    • sendPayload

      public void sendPayload(String body, boolean gzip)
      Posts one JSON array body to the intake (blocking).
      Parameters:
      body - JSON array text
      gzip - whether to gzip the body
      Throws:
      DatadogLogsException - the mapped error
    • sendPayloadAsync

      public CompletableFuture<Void> sendPayloadAsync(String body, boolean gzip)
      Posts one JSON array body to the intake.
      Parameters:
      body - JSON array text
      gzip - whether to gzip the body (Content-Encoding: gzip)
      Returns:
      a future completed on a 2xx answer, failed with the mapped error otherwise
    • shutdown

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