From 1bd570f4ba2e732122ac1d03151e8326286225af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Tue, 17 Sep 2024 09:11:09 +0200 Subject: [PATCH] Bump otel/log after introducing EnabledParameters (#6115) Follows https://github.com/open-telemetry/opentelemetry-go/pull/5791 which introduces a breaking change for the updated Go modules. --- bridges/otellogr/go.mod | 2 +- bridges/otellogr/go.sum | 4 ++-- bridges/otellogrus/go.mod | 2 +- bridges/otellogrus/go.sum | 4 ++-- bridges/otelslog/go.mod | 2 +- bridges/otelslog/go.sum | 4 ++-- bridges/otelslog/handler.go | 6 ++--- bridges/otelslog/handler_test.go | 8 +++++-- bridges/otelzap/core.go | 12 +++++----- bridges/otelzap/core_test.go | 8 +++++-- bridges/otelzap/go.mod | 2 +- bridges/otelzap/go.sum | 4 ++-- processors/minsev/go.mod | 4 ++-- processors/minsev/go.sum | 8 +++---- processors/minsev/minsev.go | 23 +++++++++++-------- processors/minsev/minsev_test.go | 39 ++++++++++++++++++++------------ 16 files changed, 77 insertions(+), 55 deletions(-) diff --git a/bridges/otellogr/go.mod b/bridges/otellogr/go.mod index 77513f200de..8679e6d578d 100644 --- a/bridges/otellogr/go.mod +++ b/bridges/otellogr/go.mod @@ -5,7 +5,7 @@ go 1.22 require ( github.com/go-logr/logr v1.4.2 github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel/log v0.6.0 + go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 ) require ( diff --git a/bridges/otellogr/go.sum b/bridges/otellogr/go.sum index 4ef1221bf13..61163c58071 100644 --- a/bridges/otellogr/go.sum +++ b/bridges/otellogr/go.sum @@ -13,8 +13,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8= -go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 h1:dD3nAsIm6kjeVCS4y3Xt2yTbauFvVGU3xcUOdfpd7bA= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= diff --git a/bridges/otellogrus/go.mod b/bridges/otellogrus/go.mod index a7c84a84b80..ae647a6cf44 100644 --- a/bridges/otellogrus/go.mod +++ b/bridges/otellogrus/go.mod @@ -5,7 +5,7 @@ go 1.22 require ( github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel/log v0.6.0 + go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 ) require ( diff --git a/bridges/otellogrus/go.sum b/bridges/otellogrus/go.sum index 5233002afba..14472b9bb61 100644 --- a/bridges/otellogrus/go.sum +++ b/bridges/otellogrus/go.sum @@ -18,8 +18,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8= -go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 h1:dD3nAsIm6kjeVCS4y3Xt2yTbauFvVGU3xcUOdfpd7bA= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= diff --git a/bridges/otelslog/go.mod b/bridges/otelslog/go.mod index ca25c81441c..c825669721a 100644 --- a/bridges/otelslog/go.mod +++ b/bridges/otelslog/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel/log v0.6.0 + go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 ) require ( diff --git a/bridges/otelslog/go.sum b/bridges/otelslog/go.sum index 4ef1221bf13..61163c58071 100644 --- a/bridges/otelslog/go.sum +++ b/bridges/otelslog/go.sum @@ -13,8 +13,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8= -go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 h1:dD3nAsIm6kjeVCS4y3Xt2yTbauFvVGU3xcUOdfpd7bA= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= diff --git a/bridges/otelslog/handler.go b/bridges/otelslog/handler.go index 3cfb5bf02b1..348cf81b1fa 100644 --- a/bridges/otelslog/handler.go +++ b/bridges/otelslog/handler.go @@ -201,10 +201,10 @@ func (h *Handler) convertRecord(r slog.Record) log.Record { // Enable returns true if the Handler is enabled to log for the provided // context and Level. Otherwise, false is returned if it is not enabled. func (h *Handler) Enabled(ctx context.Context, l slog.Level) bool { - var record log.Record + var param log.EnabledParameters const sevOffset = slog.Level(log.SeverityDebug) - slog.LevelDebug - record.SetSeverity(log.Severity(l + sevOffset)) - return h.logger.Enabled(ctx, record) + param.SetSeverity(log.Severity(l + sevOffset)) + return h.logger.Enabled(ctx, param) } // WithAttrs returns a new [slog.Handler] based on h that will log using the diff --git a/bridges/otelslog/handler_test.go b/bridges/otelslog/handler_test.go index 6618e2bed80..761889de2ee 100644 --- a/bridges/otelslog/handler_test.go +++ b/bridges/otelslog/handler_test.go @@ -70,8 +70,12 @@ type enablerKey uint var enableKey enablerKey -func (r *recorder) Enabled(ctx context.Context, record log.Record) bool { - return ctx.Value(enableKey) != nil || record.Severity() >= r.MinSeverity +func (r *recorder) Enabled(ctx context.Context, param log.EnabledParameters) bool { + lvl, ok := param.Severity() + if !ok { + return true + } + return ctx.Value(enableKey) != nil || lvl >= r.MinSeverity } func (r *recorder) Emit(_ context.Context, record log.Record) { diff --git a/bridges/otelzap/core.go b/bridges/otelzap/core.go index 594de3e3a6d..962ce5bf315 100644 --- a/bridges/otelzap/core.go +++ b/bridges/otelzap/core.go @@ -140,9 +140,9 @@ func NewCore(name string, opts ...Option) *Core { // Enabled decides whether a given logging level is enabled when logging a message. func (o *Core) Enabled(level zapcore.Level) bool { - r := log.Record{} - r.SetSeverity(convertLevel(level)) - return o.logger.Enabled(context.Background(), r) + param := log.EnabledParameters{} + param.SetSeverity(convertLevel(level)) + return o.logger.Enabled(context.Background(), param) } // With adds structured context to the Core. @@ -176,15 +176,15 @@ func (o *Core) Sync() error { // Check determines whether the supplied Entry should be logged. // If the entry should be logged, the Core adds itself to the CheckedEntry and returns the result. func (o *Core) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry { - r := log.Record{} - r.SetSeverity(convertLevel(ent.Level)) + param := log.EnabledParameters{} + param.SetSeverity(convertLevel(ent.Level)) logger := o.logger if ent.LoggerName != "" { logger = o.provider.Logger(ent.LoggerName, o.opts...) } - if logger.Enabled(context.Background(), r) { + if logger.Enabled(context.Background(), param) { return ce.AddCore(ent, o) } return ce diff --git a/bridges/otelzap/core_test.go b/bridges/otelzap/core_test.go index 016bb1486b7..0d00794b409 100644 --- a/bridges/otelzap/core_test.go +++ b/bridges/otelzap/core_test.go @@ -135,8 +135,12 @@ func TestCore(t *testing.T) { } func TestCoreEnabled(t *testing.T) { - enabledFunc := func(c context.Context, r log.Record) bool { - return r.Severity() >= log.SeverityInfo + enabledFunc := func(c context.Context, param log.EnabledParameters) bool { + lvl, ok := param.Severity() + if !ok { + return true + } + return lvl >= log.SeverityInfo } r := logtest.NewRecorder(logtest.WithEnabledFunc(enabledFunc)) diff --git a/bridges/otelzap/go.mod b/bridges/otelzap/go.mod index c63491861b4..2ef2fd00b83 100644 --- a/bridges/otelzap/go.mod +++ b/bridges/otelzap/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel/log v0.6.0 + go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 go.uber.org/zap v1.27.0 ) diff --git a/bridges/otelzap/go.sum b/bridges/otelzap/go.sum index a585c810330..0e563cc8687 100644 --- a/bridges/otelzap/go.sum +++ b/bridges/otelzap/go.sum @@ -13,8 +13,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8= -go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 h1:dD3nAsIm6kjeVCS4y3Xt2yTbauFvVGU3xcUOdfpd7bA= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= diff --git a/processors/minsev/go.mod b/processors/minsev/go.mod index db55012fbc7..933d5f26da3 100644 --- a/processors/minsev/go.mod +++ b/processors/minsev/go.mod @@ -4,8 +4,8 @@ go 1.22 require ( github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel/log v0.6.0 - go.opentelemetry.io/otel/sdk/log v0.6.0 + go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 + go.opentelemetry.io/otel/sdk/log v0.6.1-0.20240916071759-a7e83aace985 ) require ( diff --git a/processors/minsev/go.sum b/processors/minsev/go.sum index 6407ef430c6..e112a8daaee 100644 --- a/processors/minsev/go.sum +++ b/processors/minsev/go.sum @@ -15,14 +15,14 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8= -go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985 h1:dD3nAsIm6kjeVCS4y3Xt2yTbauFvVGU3xcUOdfpd7bA= +go.opentelemetry.io/otel/log v0.6.1-0.20240916071759-a7e83aace985/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= -go.opentelemetry.io/otel/sdk/log v0.6.0 h1:4J8BwXY4EeDE9Mowg+CyhWVBhTSLXVXodiXxS/+PGqI= -go.opentelemetry.io/otel/sdk/log v0.6.0/go.mod h1:L1DN8RMAduKkrwRAFDEX3E3TLOq46+XMGSbUfHU/+vE= +go.opentelemetry.io/otel/sdk/log v0.6.1-0.20240916071759-a7e83aace985 h1:fzvEpgpuicrPQ0ThuRkvovPkcjaXfvkf+1bcW0XO49U= +go.opentelemetry.io/otel/sdk/log v0.6.1-0.20240916071759-a7e83aace985/go.mod h1:L1DN8RMAduKkrwRAFDEX3E3TLOq46+XMGSbUfHU/+vE= go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= diff --git a/processors/minsev/minsev.go b/processors/minsev/minsev.go index a1997ecf4b2..fa6229f1d65 100644 --- a/processors/minsev/minsev.go +++ b/processors/minsev/minsev.go @@ -31,7 +31,7 @@ func NewLogProcessor(downstream log.Processor, minimum api.Severity) *LogProcess // filterProcessor is the experimental optional interface a Processor can // implement (go.opentelemetry.io/otel/sdk/log/internal/x). type filterProcessor interface { - Enabled(ctx context.Context, record log.Record) bool + Enabled(ctx context.Context, param api.EnabledParameters) bool } // LogProcessor is an [log.Processor] implementation that wraps another @@ -63,20 +63,25 @@ func (p *LogProcessor) OnEmit(ctx context.Context, record *log.Record) error { } // Enabled returns if the [log.Processor] that p wraps is enabled if the -// severity of record is greater than or equal to p.Minimum. Otherwise false is +// severity of param is greater than or equal to p.Minimum. Otherwise false is // returned. -func (p *LogProcessor) Enabled(ctx context.Context, record log.Record) bool { +func (p *LogProcessor) Enabled(ctx context.Context, param api.EnabledParameters) bool { + lvl, ok := param.Severity() + if !ok { + return true + } + if p.filter != nil { - return record.Severity() >= p.Minimum && p.filter.Enabled(ctx, record) + return lvl >= p.Minimum && p.filter.Enabled(ctx, param) } - return record.Severity() >= p.Minimum + return lvl >= p.Minimum } var defaultProcessor = noopProcessor{} type noopProcessor struct{} -func (p noopProcessor) OnEmit(context.Context, *log.Record) error { return nil } -func (p noopProcessor) Enabled(context.Context, log.Record) bool { return false } -func (p noopProcessor) Shutdown(context.Context) error { return nil } -func (p noopProcessor) ForceFlush(context.Context) error { return nil } +func (p noopProcessor) OnEmit(context.Context, *log.Record) error { return nil } +func (p noopProcessor) Enabled(context.Context, api.EnabledParameters) bool { return false } +func (p noopProcessor) Shutdown(context.Context) error { return nil } +func (p noopProcessor) ForceFlush(context.Context) error { return nil } diff --git a/processors/minsev/minsev_test.go b/processors/minsev/minsev_test.go index 564454260cc..a165e6008cd 100644 --- a/processors/minsev/minsev_test.go +++ b/processors/minsev/minsev_test.go @@ -22,27 +22,32 @@ var severities = []api.Severity{ api.SeverityFatal, api.SeverityFatal1, api.SeverityFatal2, api.SeverityFatal3, api.SeverityFatal4, } -type args struct { +type emitArgs struct { Ctx context.Context Record *log.Record } +type enabledArgs struct { + Ctx context.Context + Param api.EnabledParameters +} + type processor struct { ReturnErr error - OnEmitCalls []args - EnabledCalls []args + OnEmitCalls []emitArgs + EnabledCalls []enabledArgs ForceFlushCalls []context.Context ShutdownCalls []context.Context } func (p *processor) OnEmit(ctx context.Context, r *log.Record) error { - p.OnEmitCalls = append(p.OnEmitCalls, args{ctx, r}) + p.OnEmitCalls = append(p.OnEmitCalls, emitArgs{ctx, r}) return p.ReturnErr } -func (p *processor) Enabled(ctx context.Context, r log.Record) bool { - p.EnabledCalls = append(p.EnabledCalls, args{ctx, &r}) +func (p *processor) Enabled(ctx context.Context, param api.EnabledParameters) bool { + p.EnabledCalls = append(p.EnabledCalls, enabledArgs{ctx, param}) return true } @@ -105,14 +110,14 @@ func TestLogProcessorEnabled(t *testing.T) { p := NewLogProcessor(wrapped, api.SeverityTrace1) ctx := context.Background() - r := &log.Record{} + param := api.EnabledParameters{} for _, sev := range severities { - r.SetSeverity(sev) - assert.True(t, p.Enabled(ctx, *r), sev.String()) + param.SetSeverity(sev) + assert.True(t, p.Enabled(ctx, param), sev.String()) if assert.Lenf(t, wrapped.EnabledCalls, 1, "Record with severity %s not passed-through", sev) { assert.Equal(t, ctx, wrapped.EnabledCalls[0].Ctx, sev.String()) - assert.Equal(t, r, wrapped.EnabledCalls[0].Record, sev.String()) + assert.Equal(t, param, wrapped.EnabledCalls[0].Param, sev.String()) } wrapped.Reset() } @@ -123,10 +128,10 @@ func TestLogProcessorEnabled(t *testing.T) { p := NewLogProcessor(wrapped, api.SeverityFatal4+1) ctx := context.Background() - r := &log.Record{} + param := api.EnabledParameters{} for _, sev := range severities { - r.SetSeverity(sev) - assert.False(t, p.Enabled(ctx, *r), sev.String()) + param.SetSeverity(sev) + assert.False(t, p.Enabled(ctx, param), sev.String()) if !assert.Lenf(t, wrapped.EnabledCalls, 0, "Record with severity %s passed-through", sev) { wrapped.Reset() @@ -158,9 +163,11 @@ func TestLogProcessorNilDownstream(t *testing.T) { ctx := context.Background() r := new(log.Record) r.SetSeverity(api.SeverityTrace1) + param := api.EnabledParameters{} + param.SetSeverity(api.SeverityTrace1) assert.NotPanics(t, func() { assert.NoError(t, p.OnEmit(ctx, r)) - assert.False(t, p.Enabled(ctx, *r)) + assert.False(t, p.Enabled(ctx, param)) assert.NoError(t, p.ForceFlush(ctx)) assert.NoError(t, p.Shutdown(ctx)) }) @@ -169,6 +176,8 @@ func TestLogProcessorNilDownstream(t *testing.T) { func BenchmarkLogProcessor(b *testing.B) { r := new(log.Record) r.SetSeverity(api.SeverityTrace) + param := api.EnabledParameters{} + param.SetSeverity(api.SeverityTrace) ctx := context.Background() type combo interface { @@ -182,7 +191,7 @@ func BenchmarkLogProcessor(b *testing.B) { var enabled bool b.ReportAllocs() for n := 0; n < b.N; n++ { - enabled = p.Enabled(ctx, *r) + enabled = p.Enabled(ctx, param) err = p.OnEmit(ctx, r) }