-
Notifications
You must be signed in to change notification settings - Fork 1.2k
sdk/log: Add FilterProcessor and EnabledParameters #6317
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
96a79ee
mv sdk/log/internal/x sdk/xlog
pellared 6282e71
Introduce xlog module with FilterProcessor and EnabledParameters
pellared 69ff66d
Update changelog
pellared bf61d44
Add trace context fields
pellared 5b3c8ca
Test FilterProcessor functionality
pellared f24fc64
Update changelog
pellared fffc077
go mod tidy
pellared 55adcc4
Merge branch 'main' into sdk/xlogs
pellared 008cf4d
Merge branch 'main' into sdk/xlogs
pellared 4df6669
Remove span context fields from EnabledParameters
pellared d31f329
Simplify doc comments
pellared fe5ae63
go mod tidy
pellared 4e54827
Move sdk/xlog to sdk/log/xlog
pellared abe7833
Fix hyperlink
pellared d5817c6
Update README.md
pellared c23714b
Merge branch 'main' into sdk/xlogs
pellared cb91d27
Merge branch 'main' into sdk/xlogs
pellared 71376d1
Update sdk/log/example_test.go
pellared e6b34ae
Update sdk/log/logger.go
pellared 4ff41e1
Format comment
pellared 628f916
Add missing period
pellared 98d6811
Do not release xlog
pellared 5cf1eaf
Improve Go doc comments
pellared 6378ea7
Merge branch 'main' into sdk/xlogs
pellared 46ba89f
Update CHANGELOG.md
pellared c8deb2f
Promote FilterProcessor and EnabledParameters to sdk/log
pellared c1a5ad7
Update PR number
pellared a7604e1
Merge branch 'main' into filterproc
pellared daf7441
Update example_test.go
pellared 2ec602c
Update example_test.go
pellared 1cdb279
Merge branch 'main' into filterproc
pellared af3bc56
Merge branch 'main' into filterproc
pellared 40478df
Merge branch 'main' into filterproc
pellared 34bae5a
Merge branch 'main' into filterproc
pellared File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package log // import "go.opentelemetry.io/otel/sdk/log" | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "go.opentelemetry.io/otel/log" | ||
| "go.opentelemetry.io/otel/sdk/instrumentation" | ||
| "go.opentelemetry.io/otel/sdk/resource" | ||
| ) | ||
|
|
||
| // FilterProcessor is a [Processor] that knows, and can identify, what [Record] | ||
| // it will process or drop when it is passed to [Processor.OnEmit]. | ||
| // | ||
| // This is useful for users that want to know if a [log.Record] | ||
| // will be processed or dropped before they perform complex operations to | ||
| // construct the [log.Record]. | ||
| // | ||
| // The SDK's Logger.Enabled returns false | ||
| // if all the registered Processors implement FilterProcessor | ||
| // and they all return false. | ||
| // | ||
| // Processor implementations that choose to support this by satisfying this | ||
| // interface are expected to re-evaluate the [Record] passed to [Processor.OnEmit], | ||
| // it is not expected that the caller to OnEmit will use the functionality | ||
| // from this interface prior to calling OnEmit. | ||
| // | ||
| // See the [go.opentelemetry.io/contrib/processors/minsev] for an example use-case. | ||
| // It provides a Processor used to filter out [Record] | ||
| // that has a [log.Severity] below a threshold. | ||
| type FilterProcessor interface { | ||
| // Enabled returns whether the Processor will process for the given context | ||
| // and param. | ||
| // | ||
| // The passed param is likely to be a partial record information being | ||
| // provided (e.g a param with only the Severity set). | ||
| // 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 Logger will not | ||
| // emit. 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). | ||
| // | ||
| // 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. | ||
| // | ||
| // Implementations of this method need to be safe for a user to call | ||
| // concurrently. | ||
| Enabled(ctx context.Context, param EnabledParameters) bool | ||
| } | ||
|
|
||
| // EnabledParameters represents payload for [FilterProcessor]'s Enabled method. | ||
| type EnabledParameters struct { | ||
| Resource resource.Resource | ||
| InstrumentationScope instrumentation.Scope | ||
| Severity log.Severity | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.