Skip to content

Commit a6e302f

Browse files
authored
sdk/log: remove unnecessary b.q.Len() call (#6641)
Addresses #6569 (comment)
1 parent 8fd3756 commit a6e302f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2929
- Initialize map with `len(keys)` in `NewAllowKeysFilter` and `NewDenyKeysFilter` to avoid unnecessary allocations in `go.opentelemetry.io/otel/attribute`. (#6455)
3030
- `go.opentelemetry.io/otel/log/logtest` is now a separate Go module. (#6465)
3131
- `go.opentelemetry.io/otel/sdk/log/logtest` is now a separate Go module. (#6466)
32-
- Improve performance of `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot accept more. (#6569)
32+
- Improve performance of `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` by not exporting when exporter cannot accept more. (#6569, #6641)
3333

3434
### Deprecated
3535

sdk/log/batch.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (b *BatchProcessor) poll(interval time.Duration) (done chan struct{}) {
156156
global.Warn("dropped log records", "dropped", d)
157157
}
158158

159-
qLen := b.q.Len()
159+
var qLen int
160160
// Don't copy data from queue unless exporter can accept more, it is very expensive.
161161
if b.exporter.Ready() {
162162
qLen = b.q.TryDequeue(buf, func(r []Record) bool {
@@ -166,6 +166,8 @@ func (b *BatchProcessor) poll(interval time.Duration) (done chan struct{}) {
166166
}
167167
return ok
168168
})
169+
} else {
170+
qLen = b.q.Len()
169171
}
170172

171173
if qLen >= b.batchSize {

0 commit comments

Comments
 (0)