diff --git a/pkg/writers/buffer/buffer.go b/pkg/writers/buffer/buffer.go index b28b47bfa..15dacff96 100644 --- a/pkg/writers/buffer/buffer.go +++ b/pkg/writers/buffer/buffer.go @@ -23,7 +23,7 @@ func (poolMetrics) recordBufferRetrival() { func (poolMetrics) recordBufferReturn(buf *Buffer) { activeBufferCount.Dec() - totalBufferSize.Add(float64(buf.Len())) + totalBufferSize.Add(float64(buf.Cap())) totalBufferLength.Add(float64(buf.Len())) buf.recordMetric() } diff --git a/pkg/writers/buffer_writer/bufferwriter.go b/pkg/writers/buffer_writer/bufferwriter.go index 6a564f4de..8f0122223 100644 --- a/pkg/writers/buffer_writer/bufferwriter.go +++ b/pkg/writers/buffer_writer/bufferwriter.go @@ -62,8 +62,7 @@ func (b *BufferWriter) Write(data []byte) (int, error) { b.size += size start := time.Now() defer func(start time.Time) { - bufferLength := int64(b.buf.Len()) - b.metrics.recordDataProcessed(bufferLength, time.Since(start)) + b.metrics.recordDataProcessed(int64(size), time.Since(start)) }(start) return b.buf.Write(data)