diff --git a/processors/minsev/go.mod b/processors/minsev/go.mod index cb79ba6b5ef..37fefba93ec 100644 --- a/processors/minsev/go.mod +++ b/processors/minsev/go.mod @@ -4,8 +4,8 @@ go 1.21 require ( github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel/log v0.4.0 - go.opentelemetry.io/otel/sdk/log v0.4.0 + go.opentelemetry.io/otel/log v0.4.1-0.20240807055449-d0a45b887546 + go.opentelemetry.io/otel/sdk/log v0.4.1-0.20240807055449-d0a45b887546 ) require ( @@ -14,10 +14,10 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect + go.opentelemetry.io/otel v1.28.1-0.20240807055449-d0a45b887546 // indirect + go.opentelemetry.io/otel/metric v1.28.1-0.20240807055449-d0a45b887546 // indirect + go.opentelemetry.io/otel/sdk v1.28.1-0.20240807055449-d0a45b887546 // indirect + go.opentelemetry.io/otel/trace v1.28.1-0.20240807055449-d0a45b887546 // indirect + golang.org/x/sys v0.23.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/processors/minsev/go.sum b/processors/minsev/go.sum index daec7da1660..1a2a3ea4d56 100644 --- a/processors/minsev/go.sum +++ b/processors/minsev/go.sum @@ -13,20 +13,20 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= -go.opentelemetry.io/otel/log v0.4.0 h1:/vZ+3Utqh18e8TPjuc3ecg284078KWrR8BRz+PQAj3o= -go.opentelemetry.io/otel/log v0.4.0/go.mod h1:DhGnQvky7pHy82MIRV43iXh3FlKN8UUKftn0KbLOq6I= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= -go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= -go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= -go.opentelemetry.io/otel/sdk/log v0.4.0 h1:1mMI22L82zLqf6KtkjrRy5BbagOTWdJsqMY/HSqILAA= -go.opentelemetry.io/otel/sdk/log v0.4.0/go.mod h1:AYJ9FVF0hNOgAVzUG/ybg/QttnXhUePWAupmCqtdESo= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +go.opentelemetry.io/otel v1.28.1-0.20240807055449-d0a45b887546 h1:+2PkfVXGd6+uIqrsad7WJrxH/hyPcSXaJU+NBjeF2i0= +go.opentelemetry.io/otel v1.28.1-0.20240807055449-d0a45b887546/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/log v0.4.1-0.20240807055449-d0a45b887546 h1:PQA8upi2HRtSy3TIZkboP1jDoQghI0iDNZ36fbubxjk= +go.opentelemetry.io/otel/log v0.4.1-0.20240807055449-d0a45b887546/go.mod h1:DhGnQvky7pHy82MIRV43iXh3FlKN8UUKftn0KbLOq6I= +go.opentelemetry.io/otel/metric v1.28.1-0.20240807055449-d0a45b887546 h1:5Z+VcSAvUx6T5RS6VXxQTySbyuRHQ8FophCtFQlDD5U= +go.opentelemetry.io/otel/metric v1.28.1-0.20240807055449-d0a45b887546/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.1-0.20240807055449-d0a45b887546 h1:SX1P1762JFSZAEuuVdMg8LcWRz2xZwg1CuL9D0m/0jA= +go.opentelemetry.io/otel/sdk v1.28.1-0.20240807055449-d0a45b887546/go.mod h1:2rWjAcMkswukLVtzgzFcx4Ixw5JEmGaaYmMLGy6mBio= +go.opentelemetry.io/otel/sdk/log v0.4.1-0.20240807055449-d0a45b887546 h1:UpKIPgZFaN19n7PlfWKAuPrPBPVlJfbfBDNYE9RWcQk= +go.opentelemetry.io/otel/sdk/log v0.4.1-0.20240807055449-d0a45b887546/go.mod h1:+Vq8S7zgof3KWrjJaY9gekXdEhhPyHcI2vKpJ42vXXM= +go.opentelemetry.io/otel/trace v1.28.1-0.20240807055449-d0a45b887546 h1:89zRePDon3uT4t9MnJSJxfgL6AL2wQkgnWjhua993go= +go.opentelemetry.io/otel/trace v1.28.1-0.20240807055449-d0a45b887546/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/processors/minsev/minsev.go b/processors/minsev/minsev.go index 24924f9a5ed..aeb135d8946 100644 --- a/processors/minsev/minsev.go +++ b/processors/minsev/minsev.go @@ -44,7 +44,7 @@ var _ log.Processor = (*LogProcessor)(nil) // OnEmit passes ctx and r to the [log.Processor] that p wraps if the severity // of record is greater than or equal to p.Minimum. Otherwise, record is // dropped. -func (p *LogProcessor) OnEmit(ctx context.Context, record log.Record) error { +func (p *LogProcessor) OnEmit(ctx context.Context, record *log.Record) error { if record.Severity() >= p.Minimum { return p.Processor.OnEmit(ctx, record) } @@ -62,7 +62,7 @@ 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, log.Record) 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 645895a54ac..a19ad475fc2 100644 --- a/processors/minsev/minsev_test.go +++ b/processors/minsev/minsev_test.go @@ -24,7 +24,7 @@ var severities = []api.Severity{ type args struct { Ctx context.Context - Record log.Record + Record *log.Record } type processor struct { @@ -36,13 +36,13 @@ type processor struct { ShutdownCalls []context.Context } -func (p *processor) OnEmit(ctx context.Context, r log.Record) error { +func (p *processor) OnEmit(ctx context.Context, r *log.Record) error { p.OnEmitCalls = append(p.OnEmitCalls, args{ctx, r}) return p.ReturnErr } func (p *processor) Enabled(ctx context.Context, r log.Record) bool { - p.EnabledCalls = append(p.EnabledCalls, args{ctx, r}) + p.EnabledCalls = append(p.EnabledCalls, args{ctx, &r}) return true } @@ -72,11 +72,11 @@ func TestLogProcessorOnEmit(t *testing.T) { r := &log.Record{} for _, sev := range severities { r.SetSeverity(sev) - assert.ErrorIs(t, p.OnEmit(ctx, *r), assert.AnError, sev.String()) + assert.ErrorIs(t, p.OnEmit(ctx, r), assert.AnError, sev.String()) if assert.Lenf(t, wrapped.OnEmitCalls, 1, "Record with severity %s not passed-through", sev) { assert.Equal(t, ctx, wrapped.OnEmitCalls[0].Ctx, sev.String()) - assert.Equal(t, *r, wrapped.OnEmitCalls[0].Record, sev.String()) + assert.Equal(t, r, wrapped.OnEmitCalls[0].Record, sev.String()) } wrapped.Reset() } @@ -90,7 +90,7 @@ func TestLogProcessorOnEmit(t *testing.T) { r := &log.Record{} for _, sev := range severities { r.SetSeverity(sev) - assert.NoError(t, p.OnEmit(ctx, *r), assert.AnError, sev.String()) + assert.NoError(t, p.OnEmit(ctx, r), assert.AnError, sev.String()) if !assert.Lenf(t, wrapped.OnEmitCalls, 0, "Record with severity %s passed-through", sev) { wrapped.Reset() @@ -112,7 +112,7 @@ func TestLogProcessorEnabled(t *testing.T) { 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, r, wrapped.EnabledCalls[0].Record, sev.String()) } wrapped.Reset() } @@ -156,20 +156,20 @@ func TestLogProcessorShutdownPassthrough(t *testing.T) { func TestLogProcessorNilDownstream(t *testing.T) { p := NewLogProcessor(nil, api.SeverityTrace1) ctx := context.Background() - r := log.Record{} + r := new(log.Record) r.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, *r)) assert.NoError(t, p.ForceFlush(ctx)) assert.NoError(t, p.Shutdown(ctx)) }) } func BenchmarkLogProcessor(b *testing.B) { - rPtr := new(log.Record) - rPtr.SetSeverity(api.SeverityTrace) - ctx, r := context.Background(), *rPtr + r := new(log.Record) + r.SetSeverity(api.SeverityTrace) + ctx := context.Background() run := func(p log.Processor) func(b *testing.B) { return func(b *testing.B) { @@ -177,7 +177,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, *r) err = p.OnEmit(ctx, r) }