-
Notifications
You must be signed in to change notification settings - Fork 933
Add opt-in LogRecordProcessor.Enabled #4439
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
Conversation
Co-authored-by: Tyler Yahn <[email protected]>
I'm telling you the historical context as someone who was deeply involved of the original effort to design and stabilize the log API and SDK. The API and SDK were designed as simple tools to facilitate the primary use case of buffering logs in a queue to send to a OTLP network location. SDK extension points like processor and exporter were added for symmetry to traces. There was an explicit goal to not require OpenTelemetry language implementation to recreate the rich ecosystems of existing log frameworks, with long lists of appenders, encoders, etc. See that goal reflected in this text:
If OpenTelemetry log appenders were supposed to be the implementation of log APIs, we'd have a much different / richer set of capabilities. With built-in capabilities, the log SDK is pretty much only good for buffering logs before sending to an OTLP network location and that is not an accident / coincidence.
This would be analog to a new log sink like the kafka example the zap authors give.
You're right, but this is a separate issue. We would still want to make sure go log appenders are implemented at the intended level of abstraction else go users will have a very different experience than other OpenTelemetry languages. |
I get it and this is why I do not want to add any sophisticated components (like filters in log4j) but add the simplest yet flexible feature that can support multiple use cases (more in PR description). At last, it is added as a MAY. SDKs are not required to support it. For OTel Go such feature is a must have (this is not "my" opinion, but a statement that all @open-telemetry/go-maintainers agree with).
This is can be only done by implementing a zapcore.Core and this is exactly what we are doing. This is not something which you understand as a log appender. slog and logr share similar design. |
I'm not making arguments for / against this PR. This is tangential, but to me is an very important realization that helps explain the "why" behind so many things that I couldn't quite understand previously. |
Just to complete this conversation, I've sketched out an idea of how go log appenders might be adjusted to more closely match the log appender concept in other languages: open-telemetry/opentelemetry-go-contrib#6964 I don't want to distract from this PR's content anymore, so let's take any followup to that draft PR or an issue. |
@pellared - I do think #4439 (comment) may be something we should specify. It is easy to do, but something we should probably provide OOTB. |
### Context - Add context propagation through Environment Variables specification. ([#4454](#4454)) - On Propagators API, stabilize `GetAll` on the `TextMap` Extract. ([#4472](#4472)) ### Traces - Define sampling threshold field in OpenTelemetry TraceState; define the behavior of TraceIdRatioBased sampler in terms of W3C Trace Context Level 2 randomness. ([#4166](#4166)) ### Metrics - Clarify SDK behavior for Instrument Advisory Parameter. ([#4389](#4389)) ### Logs - Add `Enabled` opt-in operation to the `LogRecordProcessor`. ([#4439](#4439)) - Stabilize `Logger.Enabled`. ([#4463](#4463)) - Stabilize `EventName`. ([#4475](#4475)) ### Baggage - Add context (baggage) propagation through Environment Variables specification. ([#4454](#4454)) ### Resource - Add Datamodel for Entities. ([#4442](#4442)) ### SDK Configuration - Convert declarative config env var substitution syntax to ABNF. ([#4448](#4448)) - List declarative config supported SDK extension plugin interfaces. ([#4452](#4452)) --------- Co-authored-by: Armin Ruech <[email protected]>
Fixes #4363
Towards #4208 (uses Severity Level passed via Logger.Enabled)
Towards stabilization of OpenTelemetry Go Logs API and SDK.
Use cases
Below are some use cases where the new functionality can be used:
LogLevelEnabled
in log bridge/appender implementations. This is needed for all (but one) currently supported log bridges in OTel Go Contrib.false
).Changes
Add
Enabled
opt-in operation to theLogRecordProcessor
.I created an OTEP first which was a great for having a lot of discussions and evaluations of different proposals:
Most importantly from #4290 (comment):
I decided to name the new operation
Enabled
as:I was also considering
OnEnabled
to have the same pattern as forEmit
andOnEmit
. However, we already haveForceFlush
andShutdown
which does not follow this pattern so I preferred to keep the simpleEnabled
name. ForOnEmit
I could also imagineOnEmitted
(orOnEmitting
) which does something after (or just before like we haveOnEnding
inSpanProcessor
)OnEmit
on all registered processors were called. Yet, I do not imagine something similar forEnabled
as callingEnabled
should not have any side-effects. Therefore, I decided to name itEnabled
.I want to highlight that a processor cannot assume
Enabled
was called beforeOnEmit
, because of the following reasons:Enabled
. For example: Add Advanced Processing to Logs Supplementary Guidelines #4407.OnEmit
– SinceEnabled
is optional,OnEmit
should be able to handle filtering independently. A processor filtering events should do so inOnEmit
, not just inEnabled
.Enabled
fromOnEmit
introduces overhead, as it requires convertingOnEmit
parameters to matchEnabled
's expected input.This feature is already implemented in OpenTelemetry Go:
We have one processor in Contrib which takes advantage of this functionality:
This feautre (however with some differences) is also avaiable in OTel Rust; #4363 (comment):