-
Notifications
You must be signed in to change notification settings - Fork 896
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
OTEP: Logger.Enabled #4290
base: main
Are you sure you want to change the base?
OTEP: Logger.Enabled #4290
Conversation
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
oteps/logs/4290-logger-enabled.md
Outdated
2. Avoid allocating memory to store a log record, avoid performing computationally expensive operations and avoid exporting when emitting a log or event record is unnecessary. | ||
3. Configure a minimum a log serverity level on the SDK level. | ||
4. Filter out log and event records when they are not inside a recording span. | ||
5. Have **fine-grained** filtering control for logging pipelines without using an OpenTelemetry Collector (e.g. mobile devices, serverless, IoT). |
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.
One thing I am not so sure about.. Do we expect OTel SDK to provide such control, mimicking what is often provided by the Logging libraries themselves? They often provide sophisticated mechanisms, and it may not be worth replicating everything in OTel...
We can explicitly state that our desire is to provide some control, but not necessarily matching/competing with existing logging libraries?
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 do not expect the Logs API to be as user-friendly as the logging libraries popular for given language.
However, I think that the SDK (the logging backend) should be able handle different logging processing scenarios. E.g. sending verbose logs via user_events and warning logs via OTLP (probably I could come up with better examples). I heard that someone wanted to send non-event log records and event records to different destinations. Moreover, there is the following question in the Events Basics OTEP:
How to support routing logs from the Logs API to a language-specific logging library while simultaneously routing logs from the language-specific logging library to an OpenTelemetry Logging Exporter?
I see logging libraries as logs frontend and Logs SDK as logs backend. Logs API is the thing which bridges between the frontend and backend.
Side note: I think that even without this use case we would get the same design.
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 moved it as the last use-case given that it may be seen as the least important. a4257ef
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.
Let me know if the current way it is described looks good overall.
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.
@cijothomas, PTAL
I want to also add that some users may want to directly use Logs API without using any bridged library. See: #4352
170fb68
to
48c1e11
Compare
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.
Left a few minor comments, LGTM otherwise!
Co-authored-by: Liudmila Molkova <[email protected]>
EDIT: After a demo of the OTel Go Logs design it looks like an acceptable solution, but the OTEP should call out explicitly the optimizations we have done. E.g. that we are not looping through processors when none of them implements // Enabled returns true if at least one Processor held by the LoggerProvider
// that created the logger will process param for the provided context and param.
//
// If it is not possible to definitively determine the param will be
// processed, true will be returned by default. A value of false will only be
// returned if it can be positively verified that no Processor will process.
func (l *logger) Enabled(ctx context.Context, param log.EnabledParameters) bool {
// If there are more Processors than FilterProcessors we cannot be sure
// that all Processors will drop the record. Therefore, return true.
//
// If all Processors are FilterProcessors, check if any is enabled.
return len(l.provider.processors) > len(l.provider.fltrs) || anyEnabled(ctx, param, l.provider.fltrs)
} I also plan creating a PR for #4364 as this does not seem controversial. This should simplify this OTEP (assuming the PR will be merged). |
avoid performing computationally expensive operations, | ||
and avoid exporting | ||
when emitting a log or event record is unnecessary. | ||
3. Configure a minimum log severity level on the SDK level. |
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.
Ideally, this is configurable on a per-processor level, not just SDK wide, so you can have alternate destinations for different log severity.
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 agree. I will add this use case. Also given later I already described:
MinimumSeverityLevelProcessor
is for configuring log processing pipelines.
It is the only choice when one would like to set the minimum severity level
for a certain exporting pipeline.
For example, one batching processor would be exporting logs only above info level
via OTLP and a second simple processor would be exporting all logs to stdout.
|
||
## Explanation | ||
|
||
For (1) (2), the user can use the Logs API `Logger.Enabled` function, |
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.
These number references are confusing as the seem to be referencing something from another section.
- A declarative configuration to conveniently address | ||
the most popular use cases. |
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 seems to be doing too much. Why not just focus on adding logger enabled like the title indicates?
The purpose of this OTEP is to have an agreement that the SDK needs both:
Logger.Enabled
for customization and flexibility e.g. via extendingLogRecordProcessor
withEnabled
method, Add Enabled to LogRecordProcessor #4363LoggerConfig
fields to conveniently address the most popular use cases, especially configuring the minimum severity level, Add min_severity to LoggerConfig #4364The OTEP tries to elaborate how/why it should work well with (trace) sampling as well as Events API.
Fixes #4207
Side note: I can create issues for each "open question" for tracking purposes.