Skip to content

Commit

Permalink
Merge branch 'main' into release-1.300052.0
Browse files Browse the repository at this point in the history
  • Loading branch information
okankoAMZ authored Jan 22, 2025
2 parents b8062c5 + bc787a3 commit b0a193e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/outputs/cloudwatchlogs/internal/pusher/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
// The maximum number of log events in a batch.
reqEventsLimit = 10000
// The bytes required for metadata for each log event.
perEventHeaderBytes = 26
perEventHeaderBytes = 200
// A batch of log events in a single request cannot span more than 24 hours. Otherwise, the operation fails.
batchTimeRangeLimit = 24 * time.Hour
)
Expand Down
12 changes: 6 additions & 6 deletions plugins/outputs/cloudwatchlogs/internal/pusher/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ func TestLogEventBatch(t *testing.T) {
t.Run("HasSpace", func(t *testing.T) {
batch := newLogEventBatch(Target{Group: "G", Stream: "S"}, nil)

event := newLogEvent(time.Now(), "Test message", nil)
maxEvents := reqSizeLimit / event.eventBytes

// Add events until close to the limit
for i := 0; i < reqEventsLimit-1; i++ {
event := newLogEvent(time.Now(), "Test message", nil)
for i := 0; i < maxEvents-1; i++ {
batch.append(event)
}

assert.True(t, batch.hasSpace(100), "Batch should have space for one more small event")
assert.False(t, batch.hasSpace(reqSizeLimit), "Batch should not have space for an event that exceeds the size limit")
assert.True(t, batch.hasSpace(event.eventBytes))

// Add one more event to reach the limit
event := newLogEvent(time.Now(), "Last message", nil)
batch.append(event)

assert.False(t, batch.hasSpace(1), "Batch should not have space after reaching event limit")
assert.False(t, batch.hasSpace(event.eventBytes))
})

t.Run("Build", func(t *testing.T) {
Expand Down

0 comments on commit b0a193e

Please sign in to comment.