Class LogEventBatching
java.lang.Object
codes.grow.packages.cloudwatchlogs.LogEventBatching
Client-side PutLogEvents batching (DECISIONS 5, API.md section 2.2).
CloudWatch Logs rejects a PutLogEvents call with more than 10 000 events, more than 1 048 576 bytes (sum of UTF-8 message bytes + 26 per event), events spanning more than 24 hours or events out of chronological order. These limits are enforced here, before anything is sent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordAn event as sent to AWS. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBytes AWS adds to every event when it checks the batch size.static final intMost bytes in one PutLogEvents call (sum of UTF-8 message bytes + 26 per event).static final longLongest time span (last minus first timestamp) of one batch: 24 hours in milliseconds.static final intMost events in one PutLogEvents call. -
Method Summary
Modifier and TypeMethodDescriptionstatic LogEventBatching.BatchPlanplan(List<LogEvent> events, int maxEventBytes, OversizePolicy policy) Applies the per-event size policy, sorts events by timestamp (stable) and splits them into batches that respect every PutLogEvents limit.static StringtruncateMessage(String message, int maxBytes) Truncatesmessageon a UTF-8 character boundary so the result, including the appended" …[truncated N bytes]"marker, is at mostmaxBytesUTF-8 bytes.static intReturns the UTF-8 size of a string in bytes.
-
Field Details
-
MAX_EVENTS_PER_BATCH
public static final int MAX_EVENTS_PER_BATCHMost events in one PutLogEvents call.- See Also:
-
MAX_BATCH_BYTES
public static final int MAX_BATCH_BYTESMost bytes in one PutLogEvents call (sum of UTF-8 message bytes + 26 per event).- See Also:
-
EVENT_OVERHEAD_BYTES
public static final int EVENT_OVERHEAD_BYTESBytes AWS adds to every event when it checks the batch size.- See Also:
-
MAX_BATCH_SPAN_MS
public static final long MAX_BATCH_SPAN_MSLongest time span (last minus first timestamp) of one batch: 24 hours in milliseconds.- See Also:
-
-
Method Details
-
utf8Bytes
Returns the UTF-8 size of a string in bytes.- Parameters:
text- text- Returns:
- the size
-
truncateMessage
Truncatesmessageon a UTF-8 character boundary so the result, including the appended" …[truncated N bytes]"marker, is at mostmaxBytesUTF-8 bytes.Nis the number of bytes removed from the original. Returnsmessagewhen it already fits.- Parameters:
message- the messagemaxBytes- the limit in bytes- Returns:
- the truncated message
-
plan
public static LogEventBatching.BatchPlan plan(List<LogEvent> events, int maxEventBytes, OversizePolicy policy) Applies the per-event size policy, sorts events by timestamp (stable) and splits them into batches that respect every PutLogEvents limit.- Parameters:
events- events in any ordermaxEventBytes- per-event limit (1 to 1 048 550)policy- what to do with larger events- Returns:
- the plan
- Throws:
ValidationException- for a null event or an oversized event withOversizePolicy.ERROR
-