1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

sdk/log: remove unnecessary b.q.Len() call (#6641)

Addresses
https://github.com/open-telemetry/opentelemetry-go/pull/6569#discussion_r2037896972
This commit is contained in:
Robert Pająk
2025-04-11 10:48:01 +02:00
committed by GitHub
parent 8fd3756a62
commit a6e302fa86
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Initialize map with `len(keys)` in `NewAllowKeysFilter` and `NewDenyKeysFilter` to avoid unnecessary allocations in `go.opentelemetry.io/otel/attribute`. (#6455)
- `go.opentelemetry.io/otel/log/logtest` is now a separate Go module. (#6465)
- `go.opentelemetry.io/otel/sdk/log/logtest` is now a separate Go module. (#6466)
- Improve performance of `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot accept more. (#6569)
- Improve performance of `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot accept more. (#6569, #6641)
### Deprecated
+3 -1
View File
@@ -156,7 +156,7 @@ func (b *BatchProcessor) poll(interval time.Duration) (done chan struct{}) {
global.Warn("dropped log records", "dropped", d)
}
qLen := b.q.Len()
var qLen int
// Don't copy data from queue unless exporter can accept more, it is very expensive.
if b.exporter.Ready() {
qLen = b.q.TryDequeue(buf, func(r []Record) bool {
@@ -166,6 +166,8 @@ func (b *BatchProcessor) poll(interval time.Duration) (done chan struct{}) {
}
return ok
})
} else {
qLen = b.q.Len()
}
if qLen >= b.batchSize {