Class CloudWatchLogsExporter

java.lang.Object
codes.grow.packages.cloudwatchlogs.CloudWatchLogsExporter
All Implemented Interfaces:
LogExporter

public final class CloudWatchLogsExporter extends Object implements LogExporter
Exports log records with PutLogEvents to one group/stream (SPEC section 4 LogExporter, API.md section 3). The message of each event is the normalized LogRecord JSON (redaction already applied by the log client); the event timestamp is the record timestamp in milliseconds. The gzip option is ignored: PutLogEvents has no request compression in the AWS API model.
  • Method Details

    • group

      public String group()
      Returns the log group.
      Returns:
      the group
    • stream

      public String stream()
      Returns the log stream.
      Returns:
      the stream
    • recordToMessage

      public static String recordToMessage(LogRecord record, int maxEventBytes, OversizePolicy policy)
      Serialises a record to its normalized JSON message. When the message is larger than maxEventBytes, OversizePolicy.TRUNCATE shortens the record body so the message stays valid JSON (falling back to a plain cut only when the other fields alone are too large); OversizePolicy.DROP and OversizePolicy.ERROR return null.
      Parameters:
      record - the record
      maxEventBytes - per-event limit
      policy - oversize policy
      Returns:
      the message, or null when the record is left out
    • export

      public CompletableFuture<ExportResult> export(List<LogRecord> records, ExportOptions options)
      Description copied from interface: LogExporter
      Exports a batch. The future completes with the accepted/rejected counts; it may also complete exceptionally (treated as "all rejected"). Cancelling the future cancels the export.
      Specified by:
      export in interface LogExporter
      Parameters:
      records - records to send (never empty)
      options - gzip flag and time budget
      Returns:
      the export result
    • shutdown

      public CompletableFuture<Void> shutdown()
      Description copied from interface: LogExporter
      Releases resources. Called once by BatchProcessor.shutdown.
      Specified by:
      shutdown in interface LogExporter
      Returns:
      completes when the exporter is closed