Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions platform/logger/log_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func (logSender *LogSender) EatLogMessage(msg []byte) struct {
} else {
addedBefore := false
if !bufferLengthCondition && len(logSender.LogBuffer) == 0 { // msg longer than buffer, let's cut it
cutMark := []byte("...\n")
charToCut := len(msg) + len(cutMark) - cap(logSender.LogBuffer)
if charToCut < len(msg) {
msgCut := msg[:len(msg)-charToCut]
logSender.LogBuffer = append(logSender.LogBuffer, msgCut...)
logSender.LogBuffer = append(logSender.LogBuffer, cutMark...)
addedBefore = true
}

// Keep it simple. Drop the message if it is too long.
//
// We were cutting the message before, but it leads to broken JSONs. These JSONs where dropped by the collector
// afterward.
//
addedBefore = true

} else if len(logSender.LogBuffer)+len(msg) <= cap(logSender.LogBuffer) { // still fits in buffer
logSender.LogBuffer = append(logSender.LogBuffer, msg...)
addedBefore = true
Expand Down
4 changes: 2 additions & 2 deletions platform/logger/log_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestLogSenderSmallBuffer(t *testing.T) {
const URL = "http://localhost:8091"
const LOG_MESSAGE = "log message"
barrier := &sync.WaitGroup{}
barrier.Add(ITERATIONS)
barrier.Add(0) // all messages will be dropped
handler := &Handler{barrier: barrier}
go startHttpServer(handler, ":8091")

Expand All @@ -98,7 +98,7 @@ func TestLogSenderSmallBuffer(t *testing.T) {
assert.Equal(t, true, result.timeCondition)
}
barrier.Wait()
assert.Equal(t, int(handler.counter.Load()), BUFFER_SIZE*ITERATIONS)
assert.Equal(t, int(handler.counter.Load()), 0)
}

func TestLogSenderSmallElapsedTime(t *testing.T) {
Expand Down
Loading