Skip to content
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ release.

### Logs

- Clarify that `SeverityNumber` values are used when comparing severities.
([#4552](https://github.com/open-telemetry/opentelemetry-specification/pull/4552))

### Baggage

### Profiles
Expand Down
19 changes: 9 additions & 10 deletions specification/logs/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,12 @@ this document. This field is optional.

`SeverityNumber` is an integer number. Smaller numerical values correspond to
less severe events (such as debug events), larger numerical values correspond to
more severe events (such as errors and critical events). The following table
defines the meaning of `SeverityNumber` value:
more severe events (such as errors and critical events).

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

The following table defines the meaning of `SeverityNumber` value:

SeverityNumber range|Range name|Meaning
--------------------|----------|-------
Expand All @@ -298,11 +302,6 @@ SeverityNumber range|Range name|Meaning
17-20 |ERROR |An error event. Something went wrong.
21-24 |FATAL |A fatal error such as application or system crash.

Smaller numerical values in each range represent less important (less severe)
events. Larger numerical values in each range represent more important (more
severe) events. For example `SeverityNumber=17` describes an error that is less
critical than an error with `SeverityNumber=20`.

`SeverityNumber=0` MAY be used to represent an unspecified value.

#### Mapping of `SeverityNumber`
Expand Down Expand Up @@ -420,9 +419,9 @@ capitalization or abbreviated, e.g. "Info" vs "Information").
#### Comparing Severity

In the contexts where severity participates in less-than / greater-than
comparisons `SeverityNumber` field should be used. `SeverityNumber` can be
compared to another `SeverityNumber` or to numbers in the 1..24 range (or to the
corresponding short names).
comparisons `SeverityNumber` field should be used.
Comment thread
pellared marked this conversation as resolved.
Special handling MAY be given to `SeverityNumber=0`
when it is used to represent an unspecified severity.
Comment thread
carlosalberto marked this conversation as resolved.

### Field: `Body`

Expand Down
5 changes: 2 additions & 3 deletions specification/logs/supplementary-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,15 @@ type SeverityProcessor struct {
// if the record's severity is greater than or equal to p.Min.
// Otherwise, the record is dropped (the wrapped processor is not invoked).
func (p *SeverityProcessor) OnEmit(ctx context.Context, record *sdklog.Record) error {
if record.Severity() != log.SeverityUndefined && record.Severity() < p.Min {
if record.Severity() < p.Min {
return nil
}
return p.Processor.OnEmit(ctx, record)
}

// Enabled returns false if the severity is lower than p.Min.
func (p *SeverityProcessor) Enabled(ctx context.Context, param sdklog.EnabledParameters) bool {
sev := param.Severity
if sev != log.SeverityUndefined && sev < p.Min {
if param.Severity < p.Min {
return false
}
if fp, ok := p.Processor.(sdklog.FilterProcessor); ok {
Expand Down
Loading