-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pkg/stanza] remove all usage of Multiline from the fileconsumer package #14947
Changes from all commits
98fbbcb
b77498d
8e2b9c2
bc9fa95
51afef8
0888876
640a825
d6e57fb
2fcd82e
c48f469
38ebafa
d15e0a7
9ff504b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: pkg/stanza | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "remove all usage of Multiline from the `fileconsumer` package" | ||
|
||
# One or more tracking issues related to the change | ||
issues: [14766] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,8 @@ func NewConfig() *Config { | |
IncludeFileNameResolved: false, | ||
IncludeFilePathResolved: false, | ||
PollInterval: 200 * time.Millisecond, | ||
Splitter: helper.NewSplitterConfig(), | ||
EncodingConfig: helper.NewEncodingConfig(), | ||
Flusher: helper.NewFlusherConfig(), | ||
StartAt: "end", | ||
FingerprintSize: DefaultFingerprintSize, | ||
MaxLogSize: defaultMaxLogSize, | ||
|
@@ -57,11 +58,12 @@ type Config struct { | |
FingerprintSize helper.ByteSize `mapstructure:"fingerprint_size,omitempty"` | ||
MaxLogSize helper.ByteSize `mapstructure:"max_log_size,omitempty"` | ||
MaxConcurrentFiles int `mapstructure:"max_concurrent_files,omitempty"` | ||
Splitter helper.SplitterConfig `mapstructure:",squash,omitempty"` | ||
EncodingConfig helper.EncodingConfig `mapstructure:",squash,omitempty"` | ||
Flusher helper.FlusherConfig `mapstructure:",squash,omitempty"` | ||
} | ||
|
||
// Build will build a file input operator from the supplied configuration | ||
func (c Config) Build(logger *zap.SugaredLogger, emit EmitFunc) (*Manager, error) { | ||
func (c Config) Build(logger *zap.SugaredLogger, emit EmitFunc, opts ...FactoryOption) (*Manager, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I apologize for the delayed review - I'm finally having time to look at this again. This new parameter type is a bit confusing because the Rather than pass in options, I think we should take a step back and clarify the problems with our original plan. Then we can try to solve those problems. What specific problems do we have if we pass in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for taking the time to review this code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sure, I just want to make sure we are solving the problem you initially proposed in #14593.
I don't know that we need to worry about this case. I think if it is desired to user MultilineConfig, then that is used to generate the SplitFunc in some way. Then passing in the SplitFunc works regardless of whether or not Multiline is used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the user passes in the SplitFunc, whenever the MultilineConfig is set, the SplitFunc passed in by the user is used. Will this confuse users? Is it possible to consider throwing an error? Regarding whether to remove from the What do you think about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, but this I don't think it should work this way, even temporarily. This would be confusing. We should use MultilineConfig to generate the splitFunc, then pass it in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you, it will confuse users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the case here is that we did not remove the multilineConfig from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reconsider your opinion, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes more sense to me. I think we should try it. Thanks for finding another solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also not affect the existing interface. I will open a new PR to implement this. |
||
if emit == nil { | ||
return nil, fmt.Errorf("must provide emit function") | ||
} | ||
|
@@ -100,9 +102,16 @@ func (c Config) Build(logger *zap.SugaredLogger, emit EmitFunc) (*Manager, error | |
return nil, fmt.Errorf("`fingerprint_size` must be at least %d bytes", MinFingerprintSize) | ||
} | ||
|
||
// Ensure that encoding is buildable | ||
enc, err := c.EncodingConfig.Build() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
flusher := c.Flusher.Build() | ||
// Ensure that splitter is buildable | ||
factory := newMultilineSplitterFactory(c.Splitter.EncodingConfig, c.Splitter.Flusher, c.Splitter.Multiline) | ||
_, err := factory.Build(int(c.MaxLogSize)) | ||
factory := NewFactory(opts...) | ||
_, err = factory.Build(int(c.MaxLogSize), enc.Encoding, flusher) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -129,7 +138,8 @@ func (c Config) Build(logger *zap.SugaredLogger, emit EmitFunc) (*Manager, error | |
}, | ||
fromBeginning: startAtBeginning, | ||
splitterFactory: factory, | ||
encodingConfig: c.Splitter.EncodingConfig, | ||
encodingConfig: c.EncodingConfig, | ||
flusherConfig: c.Flusher, | ||
}, | ||
finder: c.Finder, | ||
roller: newRoller(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also take
MultilineConfig
out ofSplitterConfig
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You suggested removing it from the
fileconsumer
package earlier in #14605, so I removed it here~There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'm just trying to make sure we end up in the correct end state.