-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Move log.Processor.Enabled
to independent FilterProcessor
interfaced type
#5692
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
25 commits
Select commit
Hold shift + click to select a range
3521db9
Add FilterProcessor
MrAlias 8727522
Update the LoggerProvider and Logger
MrAlias 38abe56
Update the ContextFilterProcessor example
MrAlias f0ba53f
Add changelog entry
MrAlias 4031e03
Add BenchmarkLoggerEnabled
MrAlias 53876b0
Update provider and logger tests
MrAlias 2a3fa43
Mention FilterProcessor from the Processor docs
MrAlias b3f073f
Remove Enabled method from BatchProcessor
MrAlias 6c9ba9b
Remove Enabled method from SimpleProcessor
MrAlias 6fc46a0
Add sdk/log/internal/x pacakge
MrAlias 9555d9f
Doc experimental features in sdk/log pkg
MrAlias 2271040
Replace FilterProcessor with x.FilterProcessor
MrAlias d4e9e0f
Fix import comment for sdk/log/internal/x
MrAlias a8ee3b4
Update changelog
MrAlias 51ad24f
Update changelog with Enabled method removals
MrAlias 0535da8
Add minsev example to x README
MrAlias ba537c4
Apply suggestions from code review
MrAlias ecd21f8
Clarify the SDK Logger.Enabled behavior
MrAlias 7079a4d
Merge branch 'main' into FilterProcessor
MrAlias 98978ad
Merge branch 'main' into FilterProcessor
XSAM 67deb25
Merge branch 'main' into FilterProcessor
XSAM 3faedf8
Merge branch 'main' into FilterProcessor
MrAlias e308557
Merge branch 'main' into FilterProcessor
MrAlias 844fe0c
Merge branch 'main' into FilterProcessor
MrAlias ec06ff8
Merge branch 'main' into FilterProcessor
MrAlias 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
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,35 @@ | ||
# Experimental Features | ||
|
||
The Logs SDK contains features that have not yet stabilized. | ||
These features are added to the OpenTelemetry Go Logs SDK prior to stabilization so that users can start experimenting with them and provide feedback. | ||
|
||
These feature may change in backwards incompatible ways as feedback is applied. | ||
See the [Compatibility and Stability](#compatibility-and-stability) section for more information. | ||
|
||
## Features | ||
|
||
- [Filter Processors](#filter-processor) | ||
|
||
### Filter Processor | ||
|
||
Users of logging libraries often want to know if a log `Record` will be processed or dropped before they perform complex operations to construct the `Record`. | ||
The [`Logger`] in the Logs Bridge API provides the `Enabled` method for just this use-case. | ||
In order for the Logs Bridge SDK to effectively implement this API, it needs to be known if the registered [`Processor`]s are enabled for the `Record` within a context. | ||
A [`Processor`] that knows, and can identify, what `Record` it will process or drop when it is passed to `OnEmit` can communicate this to the SDK `Logger` by implementing the `FilterProcessor`. | ||
|
||
By default, the SDK `Logger.Enabled` will return true when called. | ||
Only if all the registered [`Processor`]s implement `FilterProcessor` and they all return `false` will `Logger.Enabled` return `false`. | ||
|
||
See the [`minsev`] [`Processor`] for an example use-case. | ||
It is used to filter `Record`s out that a have a `Severity` below a threshold. | ||
|
||
[`Logger`]: https://pkg.go.dev/go.opentelemetry.io/otel/log#Logger | ||
[`Processor`]: https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log#Processor | ||
[`minsev`]: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev | ||
|
||
## Compatibility and Stability | ||
|
||
Experimental features do not fall within the scope of the OpenTelemetry Go versioning and stability [policy](../../../../VERSIONING.md). | ||
These features may be removed or modified in successive version releases, including patch versions. | ||
|
||
When an experimental feature is promoted to a stable feature, a migration path will be included in the changelog entry of the release. |
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,46 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package x contains support for Logs SDK experimental features. | ||
package x // import "go.opentelemetry.io/otel/sdk/log/internal/x" | ||
MrAlias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/otel/log" | ||
) | ||
|
||
// FilterProcessor is a [Processor] that knows, and can identify, what | ||
// [log.Record] it will process or drop when it is passed to OnEmit. | ||
// | ||
// This is useful for users of logging libraries that want to know if a [log.Record] | ||
// will be processed or dropped before they perform complex operations to | ||
// construct the [log.Record]. | ||
// | ||
// [Processor] implementations that choose to support this by satisfying this | ||
// interface are expected to re-evaluate the [log.Record]s passed to OnEmit, it is | ||
// not expected that the caller to OnEmit will use the functionality from this | ||
// interface prior to calling OnEmit. | ||
// | ||
// This should only be implemented for [Processor]s that can make reliable | ||
// enough determination of this prior to processing a [log.Record] and where | ||
// the result is dynamic. | ||
// | ||
// [Processor]: https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log#Processor | ||
type FilterProcessor interface { | ||
// Enabled returns whether the Processor will process for the given context | ||
// and record. | ||
// | ||
// The passed record is likely to be a partial record with only the | ||
// bridge-relevant information being provided (e.g a record with only the | ||
// Severity set). If a Logger 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 record, and will be false if the Processor will not | ||
// process. An implementation should default to returning true for an | ||
// indeterminate state. | ||
// | ||
// Implementations should not modify the record. | ||
Enabled(ctx context.Context, record log.Record) bool | ||
} |
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
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.