From a69cb5110a00c6356f12de7c1a4aa847aec64cac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:18:49 -0700 Subject: [PATCH 1/2] fix(deps): update module github.com/aws/aws-sdk-go-v2/config to v1.27.34 (#6117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/aws/aws-sdk-go-v2/config](https://redirect.github.com/aws/aws-sdk-go-v2) | `v1.27.33` -> `v1.27.34` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2faws%2faws-sdk-go-v2%2fconfig/v1.27.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2faws%2faws-sdk-go-v2%2fconfig/v1.27.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2faws%2faws-sdk-go-v2%2fconfig/v1.27.33/v1.27.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2faws%2faws-sdk-go-v2%2fconfig/v1.27.33/v1.27.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/open-telemetry/opentelemetry-go-contrib). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .../github.com/aws/aws-lambda-go/otellambda/example/go.mod | 2 +- .../github.com/aws/aws-lambda-go/otellambda/example/go.sum | 4 ++-- .../github.com/aws/aws-sdk-go-v2/otelaws/example/go.mod | 2 +- .../github.com/aws/aws-sdk-go-v2/otelaws/example/go.sum | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod index ee5533e1dc1..be41c2ff8e9 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.mod @@ -11,7 +11,7 @@ replace ( require ( github.com/aws/aws-lambda-go v1.47.0 - github.com/aws/aws-sdk-go-v2/config v1.27.33 + github.com/aws/aws-sdk-go-v2/config v1.27.34 github.com/aws/aws-sdk-go-v2/service/s3 v1.61.2 go.opentelemetry.io/contrib/detectors/aws/lambda v0.55.0 go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda v0.55.0 diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum index 379e21de145..47554ac235a 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/example/go.sum @@ -4,8 +4,8 @@ github.com/aws/aws-sdk-go-v2 v1.30.5 h1:mWSRTwQAb0aLE17dSzztCVJWI9+cRMgqebndjwDy github.com/aws/aws-sdk-go-v2 v1.30.5/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4 h1:70PVAiL15/aBMh5LThwgXdSQorVr91L127ttckI9QQU= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4/go.mod h1:/MQxMqci8tlqDH+pjmoLu1i0tbWCUP1hhyMRuFxpQCw= -github.com/aws/aws-sdk-go-v2/config v1.27.33 h1:Nof9o/MsmH4oa0s2q9a0k7tMz5x/Yj5k06lDODWz3BU= -github.com/aws/aws-sdk-go-v2/config v1.27.33/go.mod h1:kEqdYzRb8dd8Sy2pOdEbExTTF5v7ozEXX0McgPE7xks= +github.com/aws/aws-sdk-go-v2/config v1.27.34 h1:5sLceuETg/215nLtY/QIVB2O6cosS0iC/Tx5oyqUhbw= +github.com/aws/aws-sdk-go-v2/config v1.27.34/go.mod h1:kEqdYzRb8dd8Sy2pOdEbExTTF5v7ozEXX0McgPE7xks= github.com/aws/aws-sdk-go-v2/credentials v1.17.32 h1:7Cxhp/BnT2RcGy4VisJ9miUPecY+lyE9I8JvcZofn9I= github.com/aws/aws-sdk-go-v2/credentials v1.17.32/go.mod h1:P5/QMF3/DCHbXGEGkdbilXHsyTBX5D3HSwcrSc9p20I= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 h1:pfQ2sqNpMVK6xz2RbqLEL0GH87JOwSxPV2rzm8Zsb74= diff --git a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.mod b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.mod index 66e3273cc77..1fa00708641 100644 --- a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.mod +++ b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.mod @@ -6,7 +6,7 @@ replace go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2 require ( github.com/aws/aws-sdk-go-v2 v1.30.5 - github.com/aws/aws-sdk-go-v2/config v1.27.33 + github.com/aws/aws-sdk-go-v2/config v1.27.34 github.com/aws/aws-sdk-go-v2/service/dynamodb v1.34.9 github.com/aws/aws-sdk-go-v2/service/s3 v1.61.2 go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.55.0 diff --git a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.sum b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.sum index 256cc9aa781..b1535797277 100644 --- a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.sum +++ b/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/example/go.sum @@ -2,8 +2,8 @@ github.com/aws/aws-sdk-go-v2 v1.30.5 h1:mWSRTwQAb0aLE17dSzztCVJWI9+cRMgqebndjwDy github.com/aws/aws-sdk-go-v2 v1.30.5/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4 h1:70PVAiL15/aBMh5LThwgXdSQorVr91L127ttckI9QQU= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4/go.mod h1:/MQxMqci8tlqDH+pjmoLu1i0tbWCUP1hhyMRuFxpQCw= -github.com/aws/aws-sdk-go-v2/config v1.27.33 h1:Nof9o/MsmH4oa0s2q9a0k7tMz5x/Yj5k06lDODWz3BU= -github.com/aws/aws-sdk-go-v2/config v1.27.33/go.mod h1:kEqdYzRb8dd8Sy2pOdEbExTTF5v7ozEXX0McgPE7xks= +github.com/aws/aws-sdk-go-v2/config v1.27.34 h1:5sLceuETg/215nLtY/QIVB2O6cosS0iC/Tx5oyqUhbw= +github.com/aws/aws-sdk-go-v2/config v1.27.34/go.mod h1:kEqdYzRb8dd8Sy2pOdEbExTTF5v7ozEXX0McgPE7xks= github.com/aws/aws-sdk-go-v2/credentials v1.17.32 h1:7Cxhp/BnT2RcGy4VisJ9miUPecY+lyE9I8JvcZofn9I= github.com/aws/aws-sdk-go-v2/credentials v1.17.32/go.mod h1:P5/QMF3/DCHbXGEGkdbilXHsyTBX5D3HSwcrSc9p20I= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 h1:pfQ2sqNpMVK6xz2RbqLEL0GH87JOwSxPV2rzm8Zsb74= 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 2/2] 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) }