Skip to content

Commit

Permalink
Use the same logger for BenchmarkLoggerEmit and BenchmarkLoggerEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Feb 13, 2025
1 parent 295a382 commit caec243
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sdk/log/logger_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/sdk/instrumentation"
)

func BenchmarkLoggerEmit(b *testing.B) {
logger := newLogger(NewLoggerProvider(), instrumentation.Scope{})
logger := newTestLogger(b)

r := log.Record{}
r.SetTimestamp(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
Expand Down Expand Up @@ -64,11 +63,7 @@ func BenchmarkLoggerEmit(b *testing.B) {
}

func BenchmarkLoggerEnabled(b *testing.B) {
provider := NewLoggerProvider(
WithProcessor(newFltrProcessor("0", false)),
WithProcessor(newFltrProcessor("1", true)),
)
logger := provider.Logger(b.Name())
logger := newTestLogger(b)
ctx := context.Background()
param := log.EnabledParameters{Severity: log.SeverityDebug}
var enabled bool
Expand All @@ -82,3 +77,11 @@ func BenchmarkLoggerEnabled(b *testing.B) {

_ = enabled
}

func newTestLogger(t testing.TB) log.Logger {
provider := NewLoggerProvider(
WithProcessor(newFltrProcessor("0", false)),
WithProcessor(newFltrProcessor("1", true)),
)
return provider.Logger(t.Name())
}

0 comments on commit caec243

Please sign in to comment.