Skip to content

Commit 39a098b

Browse files
committed
Allow users to configure initial buffer size
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 55ca3c5 commit 39a098b

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.chloggen/add-initial-buffer.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/stanza
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Allow users to configure initial buffer size
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [37786]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

pkg/stanza/fileconsumer/config.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func NewConfig() *Config {
5959
MaxConcurrentFiles: defaultMaxConcurrentFiles,
6060
StartAt: "end",
6161
FingerprintSize: fingerprint.DefaultSize,
62+
InitialBufferSize: scanner.DefaultBufferSize,
6263
MaxLogSize: reader.DefaultMaxLogSize,
6364
Encoding: defaultEncoding,
6465
FlushPeriod: reader.DefaultFlushPeriod,
@@ -77,6 +78,7 @@ type Config struct {
7778
MaxBatches int `mapstructure:"max_batches,omitempty"`
7879
StartAt string `mapstructure:"start_at,omitempty"`
7980
FingerprintSize helper.ByteSize `mapstructure:"fingerprint_size,omitempty"`
81+
InitialBufferSize helper.ByteSize `mapstructure:"initial_buffer_size,omitempty"`
8082
MaxLogSize helper.ByteSize `mapstructure:"max_log_size,omitempty"`
8183
Encoding string `mapstructure:"encoding,omitempty"`
8284
SplitConfig split.Config `mapstructure:"multiline,omitempty"`
@@ -154,7 +156,7 @@ func (c Config) Build(set component.TelemetrySettings, emit emit.Callback, opts
154156
TelemetrySettings: set,
155157
FromBeginning: startAtBeginning,
156158
FingerprintSize: int(c.FingerprintSize),
157-
InitialBufferSize: scanner.DefaultBufferSize,
159+
InitialBufferSize: int(c.InitialBufferSize),
158160
MaxLogSize: int(c.MaxLogSize),
159161
Encoding: enc,
160162
SplitFunc: splitFunc,

pkg/stanza/fileconsumer/internal/reader/reader.go

-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ func (r *Reader) readHeader(ctx context.Context) (doneReadingFile bool) {
167167
}
168168
r.headerReader = nil
169169
r.HeaderFinalized = true
170-
r.initialBufferSize = scanner.DefaultBufferSize
171170

172171
// Reset position in file to r.Offest after the header scanner might have moved it past a content token.
173172
if _, err := r.file.Seek(r.Offset, 0); err != nil {

receiver/otlpjsonfilereceiver/file_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func testdataConfigYamlAsMap() *Config {
206206
Encoding: "utf-8",
207207
StartAt: "end",
208208
FingerprintSize: 1000,
209+
InitialBufferSize: 16 * 1024,
209210
MaxLogSize: 1024 * 1024,
210211
MaxConcurrentFiles: 1024,
211212
FlushPeriod: 500 * time.Millisecond,

0 commit comments

Comments
 (0)