diff --git a/CHANGELOG.md b/CHANGELOG.md index c786921a796..65bafcede5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/specification/logs/data-model.md b/specification/logs/data-model.md index ec17ba4c0ab..3502ecad0ce 100644 --- a/specification/logs/data-model.md +++ b/specification/logs/data-model.md @@ -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 --------------------|----------|------- @@ -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` @@ -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. +Special handling MAY be given to `SeverityNumber=0` +when it is used to represent an unspecified severity. ### Field: `Body` diff --git a/specification/logs/supplementary-guidelines.md b/specification/logs/supplementary-guidelines.md index 22bd232513a..ed46c91a517 100644 --- a/specification/logs/supplementary-guidelines.md +++ b/specification/logs/supplementary-guidelines.md @@ -198,7 +198,7 @@ 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) @@ -206,8 +206,7 @@ func (p *SeverityProcessor) OnEmit(ctx context.Context, record *sdklog.Record) e // 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 {