Skip to content

Commit 1cf4da5

Browse files
author
rxie
committed
fix ADDON-18851: partial log lines: When sending lines longer than 16k, the first 16k gets send and then "the rest" up to the SPLUNK_LOGGING_DRIVER_TEMP_MESSAGES_BUFFER_SIZE
1 parent 0760b85 commit 1cf4da5

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
{
5050
"name": "SPLUNK_LOGGING_DRIVER_TEMP_MESSAGES_HOLD_DURATION",
5151
"description": "Used when logs that are chunked by docker with 16kb limit. Set how long the system can wait for the next message to come.",
52-
"value": "100ms",
52+
"value": "5s",
5353
"settable": ["value"]
5454
},
5555
{

message_processor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func (mg messageProcessor) consumeLog(lf *logPair) {
8080
curRetryNumber = 0
8181

8282
if mg.shouldSendMessage(buf.Line) {
83+
if tmpBuf.tBuf.Len() == 0 {
84+
logrus.Debug("First messaging, reseting timer")
85+
tmpBuf.bufferTimer = time.Now()
86+
}
8387
// Append to temp buffer
8488
if err := tmpBuf.append(&buf); err == nil {
8589
// Send message to splunk and json logger

partial_message_buffer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,19 @@ func (b *partialMsgBuffer) reset() {
5252
if b.bufferReset {
5353
b.tBuf.Reset()
5454
b.bufferTimer = time.Now()
55+
logrus.WithField("resetBufferTimer", b.bufferTimer).Debug("resetting buffer Timer")
5556
}
5657
}
5758

5859
func (b *partialMsgBuffer) hasHoldDurationExpired(t time.Time) bool {
5960
diff := t.Sub(b.bufferTimer)
61+
logrus.WithField("currentTime", t).WithField("bufferTime", b.bufferTimer).WithField("diff", diff).Debug("Timeout settings")
62+
logrus.WithField("partialMsgBufferHoldDuration", partialMsgBufferHoldDuration).WithField("hasHoldDurationExpired", diff > partialMsgBufferHoldDuration).Debug("check timeout")
6063
return diff > partialMsgBufferHoldDuration
6164
}
6265

6366
func (b *partialMsgBuffer) hasLengthExceeded() bool {
67+
logrus.WithField("buffer size limit exceeded", partialMsgBufferMaximum < b.tBuf.Len()).Debug("check size")
6468
return partialMsgBufferMaximum < b.tBuf.Len()
6569
}
6670

splunk_logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const (
6969
// Number of messages allowed to be queued in the channel
7070
defaultStreamChannelSize = 4 * defaultPostMessagesBatchSize
7171
// Partial log hold duration (if we are not reaching max buffer size)
72-
defaultPartialMsgBufferHoldDuration = 100 * time.Millisecond
72+
defaultPartialMsgBufferHoldDuration = 5 * time.Second
7373
// Maximum buffer size for partial logging
7474
defaultPartialMsgBufferMaximum = 1024 * 1024
7575
// Number of retry if error happens while reading logs from docker provided fifo

0 commit comments

Comments
 (0)