Skip to content

Commit

Permalink
Revert the rename
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Dec 3, 2024
1 parent 39f0f95 commit ac62cf9
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Propagate non-retryable error messages to client in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5929)
- Propagate non-retryable error messages to client in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#5929)
- Propagate non-retryable error messages to client in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#5929)
- Change `EnabledParameters` to simple `EnabledParams` in `go.opentelemetry.io/otel/log`. (#6009)
- Change `EnabledParameters` to have a `Severity` field instead of a getter and setter in `go.opentelemetry.io/otel/log`. (#6009)

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions log/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ is accepted as a `context.Context` method argument.
Calls to `Enabled` are supposed to be on the hot path and the list of arguments
can be extendend in future. Therefore, in order to reduce the number of heap
allocations and make it possible to handle new arguments, `Enabled` accepts
a `EnabledParams` struct, defined in [logger.go](logger.go), as the second
a `EnabledParameters` struct, defined in [logger.go](logger.go), as the second
method argument.

The `EnabledParams` uses fields, instead of getters and setters, to allow
simpler usage which allows configuring the `EnabledParams` in the same line
The `EnabledParameters` uses fields, instead of getters and setters, to allow
simpler usage which allows configuring the `EnabledParameters` in the same line
where `Enabled` is called.

### noop package
Expand Down
2 changes: 1 addition & 1 deletion log/internal/global/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (l *logger) Emit(ctx context.Context, r log.Record) {
}
}

func (l *logger) Enabled(ctx context.Context, param log.EnabledParams) bool {
func (l *logger) Enabled(ctx context.Context, param log.EnabledParameters) bool {
var enabled bool
if del, ok := l.delegate.Load().(log.Logger); ok {
enabled = del.Enabled(ctx, param)
Expand Down
6 changes: 3 additions & 3 deletions log/internal/global/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestLoggerConcurrentSafe(t *testing.T) {

ctx := context.Background()
var r log.Record
var param log.EnabledParams
var param log.EnabledParameters

var enabled bool
for {
Expand Down Expand Up @@ -105,14 +105,14 @@ type testLogger struct {
}

func (l *testLogger) Emit(context.Context, log.Record) { l.emitN++ }
func (l *testLogger) Enabled(context.Context, log.EnabledParams) bool {
func (l *testLogger) Enabled(context.Context, log.EnabledParameters) bool {
l.enabledN++
return true
}

func emitRecord(l log.Logger) {
ctx := context.Background()
var param log.EnabledParams
var param log.EnabledParameters
var r log.Record

_ = l.Enabled(ctx, param)
Expand Down
6 changes: 3 additions & 3 deletions log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Logger interface {
//
// Notice: Enabled is intended to be used by log bridges.
// Is should not be used for writing instrumentation.
Enabled(ctx context.Context, param EnabledParams) bool
Enabled(ctx context.Context, param EnabledParameters) bool
}

// LoggerOption applies configuration options to a [Logger].
Expand Down Expand Up @@ -136,7 +136,7 @@ func WithSchemaURL(schemaURL string) LoggerOption {
})
}

// EnabledParams represents payload for [Logger]'s Enabled method.
type EnabledParams struct {
// EnabledParameters represents payload for [Logger]'s Enabled method.
type EnabledParameters struct {
Severity Severity
}
8 changes: 4 additions & 4 deletions log/logtest/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"go.opentelemetry.io/otel/log/embedded"
)

type enabledFn func(context.Context, log.EnabledParams) bool
type enabledFn func(context.Context, log.EnabledParameters) bool

var defaultEnabledFunc = func(context.Context, log.EnabledParams) bool {
var defaultEnabledFunc = func(context.Context, log.EnabledParameters) bool {
return true
}

Expand Down Expand Up @@ -43,7 +43,7 @@ func (f optFunc) apply(c config) config { return f(c) }
// WithEnabledFunc allows configuring whether the [Recorder] is enabled for specific log entries or not.
//
// By default, the Recorder is enabled for every log entry.
func WithEnabledFunc(fn func(context.Context, log.EnabledParams) bool) Option {
func WithEnabledFunc(fn func(context.Context, log.EnabledParameters) bool) Option {
return optFunc(func(c config) config {
c.enabledFn = fn
return c
Expand Down Expand Up @@ -159,7 +159,7 @@ type logger struct {
}

// Enabled indicates whether a specific record should be stored.
func (l *logger) Enabled(ctx context.Context, opts log.EnabledParams) bool {
func (l *logger) Enabled(ctx context.Context, opts log.EnabledParameters) bool {
if l.enabledFn == nil {
return defaultEnabledFunc(ctx, opts)
}
Expand Down
16 changes: 8 additions & 8 deletions log/logtest/recorder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,29 @@ func TestLoggerEnabled(t *testing.T) {
name string
options []Option
ctx context.Context
buildEnabledParams func() log.EnabledParams
buildEnabledParams func() log.EnabledParameters

isEnabled bool
}{
{
name: "the default option enables every log entry",
ctx: context.Background(),
buildEnabledParams: func() log.EnabledParams {
return log.EnabledParams{}
buildEnabledParams: func() log.EnabledParameters {
return log.EnabledParameters{}
},

isEnabled: true,
},
{
name: "with everything disabled",
options: []Option{
WithEnabledFunc(func(context.Context, log.EnabledParams) bool {
WithEnabledFunc(func(context.Context, log.EnabledParameters) bool {
return false
}),
},
ctx: context.Background(),
buildEnabledParams: func() log.EnabledParams {
return log.EnabledParams{}
buildEnabledParams: func() log.EnabledParameters {
return log.EnabledParameters{}
},

isEnabled: false,
Expand All @@ -108,7 +108,7 @@ func TestLoggerEnabled(t *testing.T) {

func TestLoggerEnabledFnUnset(t *testing.T) {
r := &logger{}
assert.True(t, r.Enabled(context.Background(), log.EnabledParams{}))
assert.True(t, r.Enabled(context.Background(), log.EnabledParameters{}))
}

func TestRecorderEmitAndReset(t *testing.T) {
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestRecorderConcurrentSafe(t *testing.T) {
defer wg.Done()

nr := r.Logger("test")
nr.Enabled(context.Background(), log.EnabledParams{})
nr.Enabled(context.Background(), log.EnabledParameters{})
nr.Emit(context.Background(), log.Record{})

r.Result()
Expand Down
2 changes: 1 addition & 1 deletion log/noop/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ type Logger struct{ embedded.Logger }
func (Logger) Emit(context.Context, log.Record) {}

// Enabled returns false. No log records are ever emitted.
func (Logger) Enabled(context.Context, log.EnabledParams) bool { return false }
func (Logger) Enabled(context.Context, log.EnabledParameters) bool { return false }
4 changes: 2 additions & 2 deletions sdk/log/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type ContextFilterProcessor struct {
}

type filter interface {
Enabled(ctx context.Context, param logapi.EnabledParams) bool
Enabled(ctx context.Context, param logapi.EnabledParameters) bool
}

func (p *ContextFilterProcessor) OnEmit(ctx context.Context, record *log.Record) error {
Expand All @@ -100,7 +100,7 @@ func (p *ContextFilterProcessor) OnEmit(ctx context.Context, record *log.Record)
return p.Processor.OnEmit(ctx, record)
}

func (p *ContextFilterProcessor) Enabled(ctx context.Context, param logapi.EnabledParams) bool {
func (p *ContextFilterProcessor) Enabled(ctx context.Context, param logapi.EnabledParameters) bool {
p.lazyFilter.Do(func() {
if f, ok := p.Processor.(filter); ok {
p.filter = f
Expand Down
2 changes: 1 addition & 1 deletion sdk/log/internal/x/x.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ type FilterProcessor interface {
// indeterminate state.
//
// Implementations should not modify the param.
Enabled(ctx context.Context, param log.EnabledParams) bool
Enabled(ctx context.Context, param log.EnabledParameters) bool
}
4 changes: 2 additions & 2 deletions sdk/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (l *logger) Emit(ctx context.Context, r log.Record) {
// If it is not possible to definitively determine the param will be
// processed, true will be returned by default. A value of false will only be
// returned if it can be positively verified that no Processor will process.
func (l *logger) Enabled(ctx context.Context, param log.EnabledParams) bool {
func (l *logger) Enabled(ctx context.Context, param log.EnabledParameters) bool {
fltrs := l.provider.filterProcessors()
// If there are more Processors than FilterProcessors we cannot be sure
// that all Processors will drop the record. Therefore, return true.
Expand All @@ -58,7 +58,7 @@ func (l *logger) Enabled(ctx context.Context, param log.EnabledParams) bool {
return len(l.provider.processors) > len(fltrs) || anyEnabled(ctx, param, fltrs)
}

func anyEnabled(ctx context.Context, param log.EnabledParams, fltrs []x.FilterProcessor) bool {
func anyEnabled(ctx context.Context, param log.EnabledParameters, fltrs []x.FilterProcessor) bool {
for _, f := range fltrs {
if f.Enabled(ctx, param) {
// At least one Processor will process the Record.
Expand Down
4 changes: 2 additions & 2 deletions sdk/log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func TestLoggerEnabled(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, tc.logger.Enabled(tc.ctx, log.EnabledParams{}))
assert.Equal(t, tc.expected, tc.logger.Enabled(tc.ctx, log.EnabledParameters{}))
})
}
}
Expand All @@ -282,7 +282,7 @@ func BenchmarkLoggerEnabled(b *testing.B) {
)
logger := provider.Logger(b.Name())
ctx := context.Background()
param := log.EnabledParams{Severity: log.SeverityDebug}
param := log.EnabledParameters{Severity: log.SeverityDebug}
var enabled bool

b.ReportAllocs()
Expand Down
4 changes: 2 additions & 2 deletions sdk/log/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func newFltrProcessor(name string, enabled bool) *fltrProcessor {
}
}

func (p *fltrProcessor) Enabled(context.Context, log.EnabledParams) bool {
func (p *fltrProcessor) Enabled(context.Context, log.EnabledParameters) bool {
return p.enabled
}

Expand Down Expand Up @@ -388,5 +388,5 @@ func BenchmarkLoggerProviderLogger(b *testing.B) {
}

b.StopTimer()
loggers[0].Enabled(context.Background(), log.EnabledParams{})
loggers[0].Enabled(context.Background(), log.EnabledParameters{})
}

0 comments on commit ac62cf9

Please sign in to comment.