[bug] - fix buffer size metric (#2749)

* fix metric

* another fix
This commit is contained in:
ahrav 2024-04-25 11:43:38 -07:00 committed by GitHub
parent fadf9c6286
commit d89b0cdace
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View file

@ -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()
}

View file

@ -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)