Skip to content

Commit 6fc3a58

Browse files
committed
remove truncationSuffix from input plugin
1 parent 73e3c4c commit 6fc3a58

File tree

7 files changed

+4
-17
lines changed

7 files changed

+4
-17
lines changed

plugins/inputs/logfile/constants/constants.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ const (
99

1010
// PerEventHeaderBytes is the bytes required for metadata for each log event
1111
PerEventHeaderBytes = 200
12-
13-
// DefaultTruncateSuffix is the suffix added to truncated log messages
14-
DefaultTruncateSuffix = "[Truncated...]"
1512
)

plugins/inputs/logfile/fileconfig.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ func (config *FileConfig) init() error {
152152
if config.MaxEventSize == 0 {
153153
config.MaxEventSize = constants.DefaultMaxEventSize - constants.PerEventHeaderBytes
154154
}
155-
if config.TruncateSuffix == "" {
156-
config.TruncateSuffix = constants.DefaultTruncateSuffix
157-
}
158155
if config.RetentionInDays == 0 {
159156
config.RetentionInDays = -1
160157
}

plugins/inputs/logfile/logfile.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ func (t *LogFile) FindLogSrc() []logs.LogSrc {
266266
fileconfig.timestampFromLogLine,
267267
fileconfig.Enc,
268268
fileconfig.MaxEventSize,
269-
fileconfig.TruncateSuffix,
270269
fileconfig.RetentionInDays,
271270
fileconfig.BackpressureMode,
272271
)

plugins/inputs/logfile/tailersrc.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ type tailerSrc struct {
7070
timestampFn func(string) (time.Time, string)
7171
enc encoding.Encoding
7272
maxEventSize int
73-
truncateSuffix string
7473
retentionInDays int
7574

7675
outputFn func(logs.LogEvent)
@@ -98,7 +97,6 @@ func NewTailerSrc(
9897
timestampFn func(string) (time.Time, string),
9998
enc encoding.Encoding,
10099
maxEventSize int,
101-
truncateSuffix string,
102100
retentionInDays int,
103101
backpressureMode logscommon.BackpressureMode,
104102
) *tailerSrc {
@@ -116,7 +114,6 @@ func NewTailerSrc(
116114
timestampFn: timestampFn,
117115
enc: enc,
118116
maxEventSize: maxEventSize,
119-
truncateSuffix: truncateSuffix,
120117
retentionInDays: retentionInDays,
121118
backpressureFdDrop: !autoRemoval && backpressureMode == logscommon.LogBackpressureModeFDRelease,
122119
done: make(chan struct{}),

plugins/inputs/logfile/tailersrc_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestTailerSrc(t *testing.T) {
8383
parseRFC3339Timestamp,
8484
nil, // encoding
8585
constants.DefaultMaxEventSize,
86-
constants.DefaultTruncateSuffix,
8786
1,
8887
"",
8988
)
@@ -194,7 +193,6 @@ func TestEventDoneCallback(t *testing.T) {
194193
parseRFC3339Timestamp,
195194
nil, // encoding
196195
constants.DefaultMaxEventSize,
197-
constants.DefaultTruncateSuffix,
198196
1,
199197
"",
200198
)
@@ -425,7 +423,6 @@ func setupTailer(t *testing.T, multiLineFn func(string) bool, maxEventSize int,
425423
parseRFC3339Timestamp,
426424
nil, // encoding
427425
maxEventSize,
428-
constants.DefaultTruncateSuffix,
429426
1,
430427
backpressureDrop,
431428
)

plugins/outputs/cloudwatchlogs/internal/pusher/batch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
// A batch of log events in a single request cannot span more than 24 hours. Otherwise, the operation fails.
3131
batchTimeRangeLimit = 24 * time.Hour
3232
// Suffix to indicate that a message has been truncated
33-
truncationSuffix = constants.DefaultTruncateSuffix
33+
defaultTruncationSuffix = "[Truncated...]"
3434
)
3535

3636
// validateAndTruncateMessage ensures events don't exceed limit before we send to CloudWatch
@@ -42,7 +42,7 @@ func validateAndTruncateMessage(message string) string {
4242
}
4343

4444
// Truncate the message and add a suffix to indicate truncation
45-
truncatedMessage := message[:maxMessageSize-len(truncationSuffix)] + truncationSuffix
45+
truncatedMessage := message[:maxMessageSize-len(defaultTruncationSuffix)] + defaultTruncationSuffix
4646
return truncatedMessage
4747
}
4848

plugins/outputs/cloudwatchlogs/internal/pusher/batch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func TestEventValidation_Over1MB(t *testing.T) {
230230
event := newStatefulLogEvent(time.Now(), oversizeMessage, nil, nil)
231231
// The total length should still be maxMessageSize
232232
assert.Equal(t, maxMessageSize, len(event.message))
233-
assert.Equal(t, oversizeMessage[:maxMessageSize-len(truncationSuffix)]+truncationSuffix, event.message)
233+
assert.Equal(t, oversizeMessage[:maxMessageSize-len(defaultTruncationSuffix)]+defaultTruncationSuffix, event.message)
234234
}
235235

236236
func TestEventValidation_Between256KBand1MB(t *testing.T) {
@@ -262,7 +262,7 @@ func TestValidateAndTruncateMessage(t *testing.T) {
262262
{
263263
name: "Over limit",
264264
input: strings.Repeat("a", maxMessageSize+1000),
265-
expectedOutput: strings.Repeat("a", maxMessageSize-len(truncationSuffix)) + truncationSuffix,
265+
expectedOutput: strings.Repeat("a", maxMessageSize-len(defaultTruncationSuffix)) + defaultTruncationSuffix,
266266
},
267267
}
268268

0 commit comments

Comments
 (0)