diff --git a/platform/logger/log_sender.go b/platform/logger/log_sender.go index 615527cd9..46d48bb61 100644 --- a/platform/logger/log_sender.go +++ b/platform/logger/log_sender.go @@ -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 diff --git a/platform/logger/log_sender_test.go b/platform/logger/log_sender_test.go index e93a34df4..20ecab243 100644 --- a/platform/logger/log_sender_test.go +++ b/platform/logger/log_sender_test.go @@ -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") @@ -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) {