Skip to content
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

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open

Conversation

pellared
Copy link
Member

@pellared pellared commented Nov 12, 2024

The purpose of this OTEP is to have an agreement that the SDK needs both:

The 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.

Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 21, 2024
@pellared pellared removed the Stale label Nov 21, 2024
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 29, 2024
@pellared pellared removed the Stale label Nov 29, 2024
@carlosalberto carlosalberto added the OTEP OpenTelemetry Enhancement Proposal (OTEP) label Dec 5, 2024
@pellared pellared self-assigned this Dec 10, 2024
@pellared pellared changed the title [WIP] [OTEP] Logger.Enabled [WIP] OTEP: Logger.Enabled Dec 10, 2024
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).
Copy link
Member

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?

Copy link
Member Author

@pellared pellared Dec 11, 2024

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.

Copy link
Member Author

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

Copy link
Member Author

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.

Copy link
Member Author

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

@pellared pellared requested a review from cijothomas December 11, 2024 19:43
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
@pellared pellared changed the title [WIP] OTEP: Logger.Enabled OTEP: Logger.Enabled Dec 16, 2024
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
@pellared pellared marked this pull request as ready for review December 18, 2024 10:56
Copy link
Contributor

@lmolkova lmolkova left a 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!

oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
oteps/logs/4290-logger-enabled.md Outdated Show resolved Hide resolved
@pellared pellared added maintainer-request Escalated by SIG maintainers and removed maintainer-request Escalated by SIG maintainers labels Jan 17, 2025
@pellared pellared marked this pull request as draft January 21, 2025 18:42
@pellared
Copy link
Member Author

pellared commented Jan 21, 2025

During the Logs SIG meeting we agreed that LogRecordFilterer should be the "main" proposal (it is more loosely coupled, processors are not "chained" by design) and move the existing that adds Enabled to LogRecordProcessor as an alternative. It is also something which most people are familiar with.

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 and that we are only looping thrrough the processors which implement enabled.

// 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).

@pellared pellared marked this pull request as ready for review January 21, 2025 20:38
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.
Copy link
Contributor

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.

Copy link
Member Author

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,
Copy link
Contributor

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.

Comment on lines +34 to +35
- A declarative configuration to conveniently address
the most popular use cases.
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog.opentelemetry.io OTEP OpenTelemetry Enhancement Proposal (OTEP)
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

Specify how Logs SDK implements Enabled
7 participants