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

Make severity required to allow filtering by severity as early as possible #4159

Open
bogdandrutu opened this issue Jul 25, 2024 · 7 comments
Labels
sig-issue A specific SIG should look into this before discussing at the spec spec:logs Related to the specification/logs directory

Comments

@bogdandrutu
Copy link
Member

Or alternative require that severity is provided as soon as possible in the https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/event-api.md#eventlogger, see for example an anti pattern of this in java where the severity can be provided after lots of other files in https://github.com/open-telemetry/opentelemetry-java/blob/main/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventBuilder.java#L140 and that forces implementations to have to store all properties (attributes, etc.) until build time since severity can also be changed by calling setSeverity multiple times.

@bogdandrutu bogdandrutu added the spec:logs Related to the specification/logs directory label Jul 25, 2024
@jack-berg
Copy link
Member

that forces implementations to have to store all properties (attributes, etc.) until build time since severity can also be changed by calling setSeverity multiple times.

Can you expand on this? If an implementation choses a builder pattern for constructing logs as java has done, how would that implementation avoid storing all properties?

@cijothomas
Copy link
Member

Is the expectation that filtering is done at the OpenTelemetry level based on severity? (From my experience, such filtering is typically done inside the logging framework itself, so logs of undesired severity won't even reach OTel bridge layer)

@pellared
Copy link
Member

pellared commented Jul 25, 2024

Is the expectation that filtering is done at the OpenTelemetry level based on severity? (From my experience, such filtering is typically done inside the logging framework itself, so logs of undesired severity won't even reach OTel bridge layer)

Yes, we are expecting such use cases. E.g. when the minimum severity level could be set via OpenTelemetry Configuration File. Related PR: #4020.

@danielgblanco danielgblanco added the triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted label Jul 29, 2024
@bogdandrutu
Copy link
Member Author

@pellared that is different because Logger is not a real logger :) (I said this many times, but I will repeat). For EventLogger which is a real Logger, users will write events, and all the logging API I've seen they do offer a "isEnabledForLevel/Severity()" but they also allow filtering by level/severity. See a good answer from @jack-berg open-telemetry/opentelemetry-java#6603

The main idea is that an implementation of the EventLogger should be able to do minimal to zero work if filtering by severity is supported and this event will be filtered anyway. In order to do that with a "builder" pattern, what you can do is to pass the severity as an argument to the builder creation method, so that the implementation can return a no-op builder if that is the case and all calls will be no-ops. With the current API in Java at least this is impossible since the severity is not available when creating the builder, hence you need to return a real builder because you don't know if this event will or not be filtered.

@bogdandrutu
Copy link
Member Author

bogdandrutu commented Aug 1, 2024

Is the expectation that filtering is done at the OpenTelemetry level based on severity? (From my experience, such filtering is typically done inside the logging framework itself, so logs of undesired severity won't even reach OTel bridge layer)

For the EventLogger (which is a logging framework in my opinion or a thin wrapper over a logging framework) you need the level from the beginning, which is what every logging framework requires that first you provide the level and after everything else so that filtering can be done efficiently.

I expect that for the EventLogger implementation someone will use a logging framework to implement it, so hence you need the level immediately.

@cijothomas today based on the API in java (at least) https://github.com/open-telemetry/opentelemetry-java/blob/main/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLogger.java#L43 I need to create a real builder and accumulate all details for the event (create maps, etc.) because I don't know the level and cannot pass it to the logging framework, then only at the end when level is available I can do filtering, so a lot of unnecessary work before I can drop the data.

@github-actions github-actions bot added the triage:followup Needs follow up during triage label Sep 19, 2024
@mtwo mtwo added the sig-issue A specific SIG should look into this before discussing at the spec label Oct 1, 2024
@mtwo mtwo added this to Logs SIG Oct 1, 2024
@mtwo
Copy link
Member

mtwo commented Oct 1, 2024

Added to the Log / Event SIG project board

@mtwo mtwo removed triage:followup Needs follow up during triage triage:deciding:community-feedback Open to community discussion. If the community can provide sufficient reasoning, it may be accepted labels Oct 1, 2024
@pellared
Copy link
Member

pellared commented Oct 2, 2024

@bogdandrutu, what I described was just a clarification that allowing filtering by severity is needed also for logging library bridges (at least in Go). I think that nothing I wrote was against your proposal. Related issue: #4208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig-issue A specific SIG should look into this before discussing at the spec spec:logs Related to the specification/logs directory
Projects
Status: No status
Development

No branches or pull requests

6 participants