-
Notifications
You must be signed in to change notification settings - Fork 77
[confgenerator] Create LoggingReceiverMacro and LoggingProcessorMacro to generate 3p receivers implementation and update flink.
#1949
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
[confgenerator] Create LoggingReceiverMacro and LoggingProcessorMacro to generate 3p receivers implementation and update flink.
#1949
Conversation
eee67b8 to
33d98ca
Compare
confgenerator/config.go
Outdated
| Component | ||
| // Components returns fluentbit components that implement this processor. | ||
| // tag is the log tag that should be matched by those components, and uid is a string which should be used when needed to generate unique names. | ||
| Components(ctx context.Context, tag string, uid string) []fluentbit.Component |
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.
LoggingProcessor can now embed LoggingProcessorMixin instead of duplicating the signature (and you probably should move the comment into the Mixin type to preserve it
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.
Done. I also embedded LoggingReceiverMixin in LoggingReceiver.
confgenerator/logging_receivers.go
Outdated
| LoggingReceiverTypes.RegisterType(func() LoggingReceiver { return &LoggingReceiverSystemd{} }, platform.Linux) | ||
| } | ||
|
|
||
| type LoggingCompositeReceiver[R LoggingReceiverMixin, P LoggingMultiProcessorMixin] struct { |
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.
I'm struggling a bit with all the similar type names
Do you think you could write a brief comment to describe the different types and how they fit together?
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.
I added comments to the definitions of LoggingReceiverMixin, LoggingProcessorMixin, LoggingMultiProcessor and LoggingCompositeReceiver. This may need more work/added detail.
I also updated the PR description with more details about the types and naming used.
confgenerator/config.go
Outdated
| } | ||
|
|
||
| // LoggingReceiverMixin implements all the methods required to describe a logging receiver pipeline. | ||
| type LoggingReceiverMixin interface { |
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.
LoggingReceiverMixin -> InternalLoggingReceiver
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.
Done
confgenerator/config.go
Outdated
| } | ||
|
|
||
| // LoggingProcessorMixin implements the methods required to define a logging receiver pipeline. | ||
| type LoggingProcessorMixin interface { |
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.
LoggingProcessorMixin -> InternalLoggingProcessor
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.
Done
confgenerator/logging_processors.go
Outdated
| } | ||
|
|
||
| // LoggingMultiProcessorMixin implements the methods required to describe a pipeline with one or more log processors. | ||
| type LoggingMultiProcessorMixin interface { |
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.
LoggingMultiProcessorMixin -> LoggingProcessorMacro, the idea being that it's a C-style macro to transform Ops Agent processor config into Ops Agent processor(s) config
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.
Done
apps/flink.go
Outdated
| confgenerator.LoggingReceiverTypes.RegisterType(func() confgenerator.LoggingReceiver { | ||
| return &confgenerator.LoggingCompositeReceiver[LoggingReceiverMixinFlink, LoggingMultiProcessorMixinFlink]{} | ||
| }) | ||
| confgenerator.LoggingProcessorTypes.RegisterType(func() confgenerator.LoggingProcessor { |
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.
What if we add a .RegisterMacro method, to be used something like
confgenerator.LoggingProcessorTypes.RegisterMacro(&LoggingProcessorMacroFlink{})Then that method can wrap the processor in a local type that turns it into a LoggingProcessor, but that wrapping type doesn't have to leak out into the rest of Ops Agent
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.
Thank you for all the guidance, pair-programming and offline discussions.
Done! The methods implemented are currently :
RegisterLoggingCompositeReceiverMacroRegisterLoggingProcessorMacro
confgenerator/logging_processors.go
Outdated
| } | ||
|
|
||
| // LoggingMultiProcessor represents a pipeline that consists of one or more log processors. | ||
| type LoggingMultiProcessor[P LoggingMultiProcessorMixin] struct { |
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.
Let's see if we can make this an unexported internal type (see comment in flink.go)
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.
This became loggingProcessorMacroAdapter.
confgenerator/logging_receivers.go
Outdated
| // LoggingCompositeReceiver represents a pipeline that consists of one log receiver & one or more log processors. | ||
| type LoggingCompositeReceiver[R LoggingReceiverMixin, P LoggingMultiProcessorMixin] struct { | ||
| ConfigComponent `yaml:",inline"` | ||
| MultiProcessorMixin P `yaml:",inline"` |
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.
Why does this take a MultiProcessorMixin instead of just taking an InternalLoggingProcessor and deferring to that processor to construct the components?
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.
I created a LoggingComponentMacro (which has a []InternalLoggingProcessor) struct to build a LoggingCompositeReceiver with the following two structs :
ops-agent/confgenerator/logging_macros.go
Lines 26 to 33 in 441081c
| // LoggingComponentMacro is a logging component that generates other | |
| // Ops Agent receiver and/or processors as its implementation. | |
| type LoggingComponentMacro interface { | |
| Type() string | |
| // Processors returns slice of logging processors. This is an intermediate representation before sub-agent specific configurations. | |
| Processors(ctx context.Context) []InternalLoggingProcessor | |
| Receiver(ctx context.Context) InternalLoggingReceiver | |
| } |
ops-agent/confgenerator/logging_macros.go
Lines 89 to 93 in 441081c
| // loggingCompositeReceiverMacroAdapter represents a pipeline that consists of one log receiver & one or more log processors. | |
| type loggingCompositeReceiverMacroAdapter[LCM LoggingComponentMacro] struct { | |
| ConfigComponent `yaml:",inline"` | |
| ComponentMacro LCM `yaml:",inline"` | |
| } |
LoggingCompositeReceiver and update flink.LoggingComponentMacro to generate 3p receivers implementation and update flink.
LoggingComponentMacro to generate 3p receivers implementation and update flink.LoggingCompositeReceiverMacro to generate 3p receivers implementation and update flink.
LoggingCompositeReceiverMacro to generate 3p receivers implementation and update flink.Logging to generate 3p receivers implementation and update flink.
Logging to generate 3p receivers implementation and update flink.LoggingReceiverMacro to generate 3p receivers implementation and update flink.
LoggingReceiverMacro to generate 3p receivers implementation and update flink.LoggingReceiverMacro and LoggingProcessorMacro to generate 3p receivers implementation and update flink.
ddd3dee to
c3f087b
Compare
…ver` and `LoggingMultiProcessor` and their building blocks.
… in `LoggingReceiver` and `LoggingProcessor` respectively. Update comments.
…ingCompositeReceiver
…and `LoggingCompositeReceiver`.
…gingProcessorMacro`), and three helper registration functions to simplify app implementations
c3f087b to
ae4e1ed
Compare
Description
Created
LoggingReceiverMacroandLoggingProcessorMacroto standardize implementation of 3rd party app logging receivers and processors. They work as a "macro" in the sense that after defining a reduced sub-agent (otel or fluent-bit) agnostic definition of a receiver or processor, the "macro" is "expanded/replaced" with a full implementation of a configurableLoggingReceiverorLoggingProcessor. Co-author @quentinmit.A list of additions in this PR :
Created
LoggingReceiverMacro,LoggingProcessorMacroto encapsulate the key elements of aLoggingReceiver,LoggingProcessor, respectively. The "macros" only need a sub-agent (otel or fluent-bit) agnostic definition of the key methods required by theLogging(Receiver|Processor). This definitions help to reduce the redundant code while defining a large number of 3p receivers.Created
RegisterLoggingReceiverMacroandRegisterLoggingProcessorMacromethods which "generate/expand/replace" the "Macro" definitions with a fully implementedLoggingReceiverofLoggingProcessor. AdditionallyRegisterLoggingFilesProcessorMacrowas created to simplify the most common definition of 3P app receivers (files receiver + processors).Created un-exported
loggingReceiverMacroAdapterandloggingProcessorMacroAdapterwhich adapt the "macro" definitions with a fully implementedLoggingReceiverorLoggingProcessor.Context
Based on the following :
LoggingCompositeReceiverto standardize implementation of 3rd party app logging receivers. #1896Related issue
b/401028449
How has this been tested?
Checklist: