-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[reflect] sdk/log/xlog: Add FilterProcessor and EnabledParameters #6286
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
Changes from 24 commits
96a79ee
6282e71
69ff66d
bf61d44
5b3c8ca
f24fc64
fffc077
55adcc4
008cf4d
4df6669
d31f329
fe5ae63
4e54827
abe7833
d5817c6
c23714b
cb91d27
71376d1
e6b34ae
4ff41e1
628f916
98d6811
5cf1eaf
9037771
3a07761
c56e9da
91d84a9
685a417
0547924
7075931
648e21f
2941fb3
2a93c9f
9da340a
d55948e
08ac146
9475ed8
25937e0
e4d1ebf
2ac7f71
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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ require ( | |
| go.opentelemetry.io/otel v1.34.0 | ||
| go.opentelemetry.io/otel/log v0.10.0 | ||
| go.opentelemetry.io/otel/sdk v1.34.0 | ||
| go.opentelemetry.io/otel/sdk/log/xlog v0.0.0-00010101000000-000000000000 | ||
|
||
| go.opentelemetry.io/otel/trace v1.34.0 | ||
| ) | ||
|
|
||
|
|
@@ -29,6 +30,8 @@ replace go.opentelemetry.io/otel/trace => ../../trace | |
|
|
||
| replace go.opentelemetry.io/otel/sdk => ../ | ||
|
|
||
| replace go.opentelemetry.io/otel/sdk/log/xlog => ./xlog | ||
|
|
||
| replace go.opentelemetry.io/otel/log => ../../log | ||
|
|
||
| replace go.opentelemetry.io/otel => ../.. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package internal | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "go.opentelemetry.io/otel/log" | ||
| "go.opentelemetry.io/otel/sdk/instrumentation" | ||
| "go.opentelemetry.io/otel/sdk/resource" | ||
| ) | ||
|
|
||
| // FilterProcessor is a [go.opentelemetry.io/otel/sdk/log.Processor] that knows, | ||
| // and can identify, what [go.opentelemetry.io/otel/sdk/log.Record] | ||
| // it will process or drop when it is passed to [go.opentelemetry.io/otel/sdk/log.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 [go.opentelemetry.io/otel/sdk/log.Record] | ||
| // passed to [go.opentelemetry.io/otel/sdk/log.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 [go.opentelemetry.io/otel/sdk/log.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.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.