diff --git a/sdk/log/logger_test.go b/sdk/log/logger_test.go index 35ebd0d11537..4ab346a14307 100644 --- a/sdk/log/logger_test.go +++ b/sdk/log/logger_test.go @@ -215,8 +215,9 @@ func TestLoggerEmit(t *testing.T) { } func TestLoggerEnabled(t *testing.T) { - p0, p1, p2WithDisabled := newProcessor("0"), newProcessor("1"), newProcessor("2") - p2WithDisabled.enabled = false + p0 := newFilterProcessor("0", true) + p1 := newFilterProcessor("1", true) + p2WithDisabled := newFilterProcessor("2", false) testCases := []struct { name string diff --git a/sdk/log/provider_test.go b/sdk/log/provider_test.go index 39071b6a98f7..122ea30b6b41 100644 --- a/sdk/log/provider_test.go +++ b/sdk/log/provider_test.go @@ -31,11 +31,10 @@ type processor struct { forceFlushCalls int records []Record - enabled bool } func newProcessor(name string) *processor { - return &processor{Name: name, enabled: true} + return &processor{Name: name} } func (p *processor) OnEmit(ctx context.Context, r *Record) error { @@ -47,10 +46,6 @@ func (p *processor) OnEmit(ctx context.Context, r *Record) error { return nil } -func (p *processor) Enabled(context.Context, Record) bool { - return p.enabled -} - func (p *processor) Shutdown(context.Context) error { p.shutdownCalls++ return p.Err @@ -61,6 +56,23 @@ func (p *processor) ForceFlush(context.Context) error { return p.Err } +type filterProcessor struct { + *processor + + enabled bool +} + +func newFilterProcessor(name string, enabled bool) *filterProcessor { + return &filterProcessor{ + processor: newProcessor(name), + enabled: enabled, + } +} + +func (p *filterProcessor) Enabled(context.Context, Record) bool { + return p.enabled +} + func TestNewLoggerProviderConfiguration(t *testing.T) { t.Cleanup(func(orig otel.ErrorHandler) func() { otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {