Skip to content

Clarify log record severity comparison #4552

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

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

Conversation

pellared
Copy link
Member

@pellared pellared commented Jun 12, 2025

Follows:

Why

Related to #4540

Supersedes #4541 per #4541 (comment) and discussions from the last OTel Specification and Logs SIG meetings.

Some comments that were already expressed as comments.

From #4541 (comment):

I'd be in favor of treating 0 as yet another severity when it comes to filtering and comparison, i.e. logs with unspecified/0 severity are dropped when threshold > 0 and are recorded otherwise.

From #4541 (comment):

I think I like the simplicity of

if sev < p.Min {
// drop
}

it provides a very reasonable default behavior, which is to drop logs that don't have any severity

This is also inline with

If the source format has only a single severity that matches the meaning of the
range then it is recommended to assign that severity the smallest value of the
range.
For example if the source format has an "Informational" log level and no other
log levels with similar meaning then it is recommended to use
`SeverityNumber=9` for "Informational".

From #4540 (comment):

Relying on int comparison seems to be the most natural option

We agreed that this PR does conflict proposal to allow only allow/support 0..24 SeverityNumber values.

What

Removal of

SeverityNumber can be compared to another SeverityNumber or to numbers in the 1..24 range (or to the corresponding short names).

as I find that this sentence is more confusing than clarifying:

  1. why comparing values of different types?
  2. why can we compare only with integers between 1..24?
  3. what about SeverityNumber that are greater than 24 or lesser than 1?
  4. are the short names normative?

Removal of duplicated description

Smaller numerical values in each range represent less important (less severe) events. Larger numerical values in each range represent more important (more severe) events.

Moving the comparison example to a better place where the SeverityNumber comparison is described

For example SeverityNumber=17 describes an error that is less critical than an error with SeverityNumber=20.

Simplify SeverityProcessor example.

Prototype

This is exactly how https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev currently works.

@pellared pellared moved this to In progress in Logs SIG Jun 12, 2025
@pellared pellared self-assigned this Jun 12, 2025
@pellared pellared added spec:logs Related to the specification/logs directory area:data-model For issues related to data model clarification clarify ambiguity in specification labels Jun 12, 2025
@pellared pellared marked this pull request as ready for review June 12, 2025 13:01
@pellared pellared requested review from a team as code owners June 12, 2025 13:01
@bixu

This comment was marked as resolved.

@trask trask changed the title Clarify log record serverty comparison Clarify log record severity comparison Jun 12, 2025
@pellared
Copy link
Member Author

pellared commented Jun 12, 2025

@pellared pellared requested a review from trask June 12, 2025 14:17
@pellared
Copy link
Member Author

pellared commented Jun 17, 2025

SIG meeting notes:
Because of e.g. https://protobuf.dev/programming-guides/enum/#java it is safer to allow only 0..24 values.
I am going to propose a separate issues/PRs to address it.

@pellared pellared marked this pull request as draft June 17, 2025 15:35
@pellared pellared marked this pull request as draft June 17, 2025 15:35
@pellared
Copy link
Member Author

pellared commented Jun 24, 2025

Because of e.g. https://protobuf.dev/programming-guides/enum/#java it is safer to allow only 0..24 values.
I am going to propose a separate issues/PRs to address it.

I feel that this PR does not contradict with the proposal to allow only 0..24 when exporting via OTLP.
Therefore, I am planing to reopen this PR once #4535 is merged.

@pellared
Copy link
Member Author

pellared commented Jun 24, 2025

Logs SIG meeting:
We agreed that this PR does conflict proposal to allow only allow/support 0..24 SeverityNumber values and that this PR polishes and clarifies the specification.

We also agreed that, due to the current state of Logs language implementations and the OTLP proto definition, we can only RECOMMEND using values between 0 and 24.

@pellared pellared marked this pull request as ready for review June 24, 2025 17:57
corresponding short names).
comparisons `SeverityNumber` field should be used.
Special handling MAY be given to `SeverityNumber=0`
when it is used to represent an unspecified severity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know whether SeverityNumberr=0 if used as unspecified value or not?

Copy link
Member Author

@pellared pellared Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is applicable for language implementations where SeverityNumber=0 represents unspecified value. For them SeverityNumber=0 is always used to say that the value is unspecified.

I am not sure if we need to say anything for languages like Rust or Swift.
@open-telemetry/rust-maintainers, @open-telemetry/swift-maintainers: WDYT?

Reference: #4535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:data-model For issues related to data model clarification clarify ambiguity in specification spec:logs Related to the specification/logs directory
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

6 participants