fix(common.ratelimiter): Only grow the buffer but never shrink (#16868)

This commit is contained in:
Sven Rebhan 2025-05-01 13:28:27 -05:00 committed by GitHub
parent e25bc43e35
commit b490846d24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -51,7 +51,7 @@ func (s *IndividualSerializer) SerializeBatch(metrics []telegraf.Metric, limit i
// Grow the buffer so it can hold at least the required size. This will
// save us from reallocate often
s.buffer.Reset()
if limit > 0 && limit < int64(math.MaxInt) {
if limit > 0 && limit > int64(s.buffer.Cap()) && limit < int64(math.MaxInt) {
s.buffer.Grow(int(limit))
}