Skip to content

Commit

Permalink
otelzerolog: Add benchmark (#5925)
Browse files Browse the repository at this point in the history
part of #5405
Added benchmark for zerolog
The result I got for the benchmark:

```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/contrib/bridges/otelzerolog
cpu: Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
BenchmarkHookRun-4   	  697216	      2059 ns/op	    1773 B/op	       0 allocs/op
PASS
ok  	go.opentelemetry.io/contrib/bridges/otelzerolog	3.110s
```
  • Loading branch information
AkhigbeEromo authored Jul 19, 2024
1 parent 000758e commit 47ee98d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bridges/otelzerolog/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,17 @@ func TestConvertLevel(t *testing.T) {
})
}
}

func BenchmarkHookRun(b *testing.B) {
rec := logtest.NewRecorder()
hook := NewHook(loggerName, WithLoggerProvider(rec))
logger := zerolog.New(nil).Hook(hook)
level := zerolog.InfoLevel
msg := "benchmark log message"
event := logger.Info()
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
hook.Run(event, level, msg)
}
}

0 comments on commit 47ee98d

Please sign in to comment.