Skip to content

Commit ca8c1ad

Browse files
authored
[pkg/stanza] Clean up split package (#26544)
Subset of #26241 Follows #26540 - Rename `MultilineConfig` to `split.Config` - Remove `Multiline`, previously a struct representation that only wrapped a split func - Remove `NewMultilineConfig`, because `split.Config` is just two simple fields with "" defaults. - Condense references in tests - Substantially increate test coverage in `split` package.
1 parent fd1deff commit ca8c1ad

File tree

19 files changed

+433
-286
lines changed

19 files changed

+433
-286
lines changed

.chloggen/pkg-stanza-rm-tokenize.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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: breaking
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: Rename "tokenize" package to "split"
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: [26540]
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+
- Remove 'Multiline' struct
20+
- Remove 'NewMultilineConfig' struct
21+
- Rename 'MultilineConfig' to 'split.Config'
22+
23+
# If your change doesn't affect end users or the exported elements of any package,
24+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
25+
# Optional: The change log or logs in which this entry should be included.
26+
# e.g. '[user]' or '[user, api]'
27+
# Include 'user' if the change is relevant to end users.
28+
# Include 'api' if there is a change to a library API.
29+
# Default: '[user]'
30+
change_logs: [api]

pkg/stanza/fileconsumer/config.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/fileconsumer/matcher"
2121
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator"
2222
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper"
23-
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/tokenize"
23+
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/split"
2424
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/trim"
2525
)
2626

@@ -53,7 +53,6 @@ func NewConfig() *Config {
5353
IncludeFileNameResolved: false,
5454
IncludeFilePathResolved: false,
5555
PollInterval: 200 * time.Millisecond,
56-
Multiline: tokenize.NewMultilineConfig(),
5756
Encoding: defaultEncoding,
5857
StartAt: "end",
5958
FingerprintSize: fingerprint.DefaultSize,
@@ -66,22 +65,22 @@ func NewConfig() *Config {
6665
// Config is the configuration of a file input operator
6766
type Config struct {
6867
matcher.Criteria `mapstructure:",squash"`
69-
IncludeFileName bool `mapstructure:"include_file_name,omitempty"`
70-
IncludeFilePath bool `mapstructure:"include_file_path,omitempty"`
71-
IncludeFileNameResolved bool `mapstructure:"include_file_name_resolved,omitempty"`
72-
IncludeFilePathResolved bool `mapstructure:"include_file_path_resolved,omitempty"`
73-
PollInterval time.Duration `mapstructure:"poll_interval,omitempty"`
74-
StartAt string `mapstructure:"start_at,omitempty"`
75-
FingerprintSize helper.ByteSize `mapstructure:"fingerprint_size,omitempty"`
76-
MaxLogSize helper.ByteSize `mapstructure:"max_log_size,omitempty"`
77-
MaxConcurrentFiles int `mapstructure:"max_concurrent_files,omitempty"`
78-
MaxBatches int `mapstructure:"max_batches,omitempty"`
79-
DeleteAfterRead bool `mapstructure:"delete_after_read,omitempty"`
80-
Multiline tokenize.MultilineConfig `mapstructure:"multiline,omitempty"`
81-
TrimConfig trim.Config `mapstructure:",squash,omitempty"`
82-
Encoding string `mapstructure:"encoding,omitempty"`
83-
FlushPeriod time.Duration `mapstructure:"force_flush_period,omitempty"`
84-
Header *HeaderConfig `mapstructure:"header,omitempty"`
68+
IncludeFileName bool `mapstructure:"include_file_name,omitempty"`
69+
IncludeFilePath bool `mapstructure:"include_file_path,omitempty"`
70+
IncludeFileNameResolved bool `mapstructure:"include_file_name_resolved,omitempty"`
71+
IncludeFilePathResolved bool `mapstructure:"include_file_path_resolved,omitempty"`
72+
PollInterval time.Duration `mapstructure:"poll_interval,omitempty"`
73+
StartAt string `mapstructure:"start_at,omitempty"`
74+
FingerprintSize helper.ByteSize `mapstructure:"fingerprint_size,omitempty"`
75+
MaxLogSize helper.ByteSize `mapstructure:"max_log_size,omitempty"`
76+
MaxConcurrentFiles int `mapstructure:"max_concurrent_files,omitempty"`
77+
MaxBatches int `mapstructure:"max_batches,omitempty"`
78+
DeleteAfterRead bool `mapstructure:"delete_after_read,omitempty"`
79+
SplitConfig split.Config `mapstructure:"multiline,omitempty"`
80+
TrimConfig trim.Config `mapstructure:",squash,omitempty"`
81+
Encoding string `mapstructure:"encoding,omitempty"`
82+
FlushPeriod time.Duration `mapstructure:"force_flush_period,omitempty"`
83+
Header *HeaderConfig `mapstructure:"header,omitempty"`
8584
}
8685

8786
type HeaderConfig struct {
@@ -101,7 +100,7 @@ func (c Config) Build(logger *zap.SugaredLogger, emit emit.Callback) (*Manager,
101100
}
102101

103102
// Ensure that splitter is buildable
104-
factory := splitter.NewMultilineFactory(c.Multiline, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod)
103+
factory := splitter.NewMultilineFactory(c.SplitConfig, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod)
105104
if _, err := factory.Build(); err != nil {
106105
return nil, err
107106
}

0 commit comments

Comments
 (0)