From 05c28c66e7559ae93b1df29e8adc64fe7f29136d Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Wed, 4 Jun 2025 08:25:36 +0200 Subject: [PATCH 1/2] Fix SeverityProcessor example --- CHANGELOG.md | 4 ++++ specification/logs/supplementary-guidelines.md | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aabb68ba04b..72971f65c7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ release. ### Logs +- Fix the `SeverityProcessor` example implementation so that it filters out only + the records with `SeverityNumber` in the 1..24 range. + ([#4540](https://github.com/open-telemetry/opentelemetry-specification/pull/4540)) + ### Baggage ### Resource diff --git a/specification/logs/supplementary-guidelines.md b/specification/logs/supplementary-guidelines.md index 67346488ad6..2131df3a50b 100644 --- a/specification/logs/supplementary-guidelines.md +++ b/specification/logs/supplementary-guidelines.md @@ -195,19 +195,22 @@ type SeverityProcessor struct { } // OnEmit passes ctx and record to the wrapped sdklog.Processor -// if the record's severity is greater than or equal to p.Min. +// if the record's severity is greater than or equal to p.Min +// or oustide the log.SeverityTrace1..log.SeverityFatal4 range. // 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 { + sev := record.Severity() + if sev >= log.SeverityTrace1 && sev <= log.SeverityFatal4 && sev < p.Min { return nil } return p.Processor.OnEmit(ctx, record) } -// Enabled returns false if the severity is lower than p.Min. +// Enabled returns false if the severity is lower than p.Min +// and inside the log.SeverityTrace1..log.SeverityFatal4 range. func (p *SeverityProcessor) Enabled(ctx context.Context, param sdklog.EnabledParameters) bool { sev := param.Severity - if sev != log.SeverityUndefined && sev < p.Min { + if sev >= log.SeverityTrace1 && sev <= log.SeverityFatal4 && sev < p.Min { return false } if fp, ok := p.Processor.(sdklog.FilterProcessor); ok { From f3837726b39bc4507de945a1b937d136a09720df Mon Sep 17 00:00:00 2001 From: Robert Pajak Date: Wed, 4 Jun 2025 08:26:13 +0200 Subject: [PATCH 2/2] Update PR number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72971f65c7e..f7cac0e5e05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ release. - Fix the `SeverityProcessor` example implementation so that it filters out only the records with `SeverityNumber` in the 1..24 range. - ([#4540](https://github.com/open-telemetry/opentelemetry-specification/pull/4540)) + ([#4541](https://github.com/open-telemetry/opentelemetry-specification/pull/4541)) ### Baggage