-
Notifications
You must be signed in to change notification settings - Fork 1.2k
sdk/log: move Enabled method from FilterProcessor to Processor #7639
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
base: main
Are you sure you want to change the base?
Conversation
Enabled method from FilterProcessor to Processor interface
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7639 +/- ##
=======================================
- Coverage 86.1% 86.1% -0.1%
=======================================
Files 298 298
Lines 21694 21694
=======================================
- Hits 18695 18693 -2
- Misses 2623 2625 +2
Partials 376 376
🚀 New features to boost your workflow:
|
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.
Pull request overview
This pull request simplifies the Logs SDK by consolidating processor capabilities into a single unified interface. Previously, processors that wanted to support filtering had to implement a separate FilterProcessor interface with an Enabled method. Now, all processors must implement the Enabled method as part of the core Processor interface.
Key Changes:
- The
Enabled(ctx context.Context, param EnabledParameters) boolmethod has been moved from theFilterProcessorinterface to theProcessorinterface - The
FilterProcessorinterface and thefilter_processor.gofile have been removed entirely - The
EnabledParametersstruct has been moved toprocessor.go
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/log/processor.go | Adds Enabled method and EnabledParameters struct to the core Processor interface, updates documentation |
| sdk/log/filter_processor.go | Removes the entire file containing the FilterProcessor interface |
| sdk/log/simple.go | Implements the Enabled method for SimpleProcessor, returning true for all records |
| sdk/log/batch.go | Implements the Enabled method for BatchProcessor, returning true for all records |
| sdk/log/provider.go | Removes tracking of FilterProcessor separately from Processor, simplifies processor registration |
| sdk/log/logger.go | Simplifies Enabled logic to iterate through all processors instead of tracking filter processors separately |
| sdk/log/provider_test.go | Adds Enabled method to test processor, removes FilterProcessor interface assertion |
| sdk/log/example_test.go | Renames example function, adds Enabled implementation to example processors, simplifies ContextFilterProcessor |
| sdk/log/bench_test.go | Updates benchmark processor Enabled signatures to use EnabledParameters instead of Record |
| CHANGELOG.md | Documents the addition of Enabled to Processor interface and removal of FilterProcessor interface |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // The passed param is likely to be partial record information being | ||
| // provided (e.g. a param with only the Severity set). |
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 comment text seems to apply more to the previous version. EnabledParameters contains at most the Severity and EventName.
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.
Which is still partial record information. This may contain more fields in the future. Still we can rephrase it if you have a proposal.
Yet, I prefer doing it in a separate PR. This PR tries to keep the existing documentation.
| // If a Processor needs more information than is provided, it | ||
| // is said to be in an indeterminate state (see below). | ||
| // | ||
| // The returned value will be true when the Processor will process for the | ||
| // provided context and param, and will be false if the Processor will not | ||
| // process. The returned value may be true or false in an indeterminate state. | ||
| // An implementation should default to returning true for an indeterminate | ||
| // state, but may return false if valid reasons in particular circumstances | ||
| // exist (e.g. performance, correctness). |
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 can't see why this belongs as documentation in the interface. What would I as a user do based on this information?
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 is for users implementing this interface.
I will try rephrasing but I prefer doing it in a separate PR. This PR tries to keep the existing documentation.
| // The param should not be held by the implementation. A copy should be | ||
| // made if the param needs to be held after the call returns. | ||
| // | ||
| // Processor implementations are expected to re-evaluate the [Record] passed | ||
| // to OnEmit. It is not expected that the caller to OnEmit will | ||
| // use the result from Enabled prior to calling OnEmit. |
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 all seems to apply only to the previous implementation?
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.
The implementation has not changed. However, I think you are right that this comment is unnecessary (param is immutable).
I will propose removing but I prefer doing it in a separate PR. This PR tries to keep the existing documentation.
| // The SDK's Logger.Enabled returns false if all the registered processors | ||
| // return false. Otherwise, it returns true. |
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.
Belongs with Logger; does not belong on the generic 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.
The issue is that the Logger implantation is not exported so I am not sure where is a better place to put this information. Do you have any proposal?
|
|
||
| type attrAddProcessor struct{} | ||
|
|
||
| func (attrAddProcessor) Enabled(context.Context, EnabledParameters) bool { |
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.
Nit: moving this up 7 lines creates unnecessary diffs.
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.
True. I wanted to keep consistency in the repo and have Enabled method before OnEmit. 234241d. Should I scope it to a separate PR?
|
|
||
| type attrSetDecorator struct{} | ||
|
|
||
| func (attrSetDecorator) Enabled(context.Context, EnabledParameters) bool { |
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.
Nit: moving this up 7 lines creates unnecessary diffs.
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.
Ditto
Why
Fixes #7617
Simplify the Logs SDK by unifying processor capabilities into a single interface.
What
Enabled(ctx context.Context, p EnabledParameters) booltosdk/log.Processor.sdk/log.FilterProcessorinterface.Processorimplementations must now implement theEnabledmethod.Custom processors that do not filter records can implement
Enabledto returntrue.