Skip to content

Commit

Permalink
update buffer metrics (#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Apr 24, 2024
1 parent ea4d9d2 commit 97599b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/writers/buffer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var (
Subsystem: common.MetricsSubsystem,
Name: "checkout_duration_us",
Help: "Duration in microseconds of Buffer checkouts.",
Buckets: []float64{50, 500, 5000},
Buckets: prometheus.ExponentialBuckets(10, 10, 7),
})

checkoutCount = promauto.NewCounter(prometheus.CounterOpts{
Expand Down
6 changes: 3 additions & 3 deletions pkg/writers/buffer_writer/bufferwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

type metrics struct{}

func (metrics) recordDataProcessed(size uint64, dur time.Duration) {
totalWriteSize.Add(float64(size))
func (metrics) recordDataProcessed(size int64, dur time.Duration) {
writeSize.Observe(float64(size))
totalWriteDuration.Add(float64(dur.Microseconds()))
}

Expand Down Expand Up @@ -62,7 +62,7 @@ func (b *BufferWriter) Write(data []byte) (int, error) {
b.size += size
start := time.Now()
defer func(start time.Time) {
bufferLength := uint64(b.buf.Len())
bufferLength := int64(b.buf.Len())
b.metrics.recordDataProcessed(bufferLength, time.Since(start))

}(start)
Expand Down
7 changes: 4 additions & 3 deletions pkg/writers/buffer_writer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
)

var (
totalWriteSize = promauto.NewCounter(prometheus.CounterOpts{
writeSize = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: common.MetricsNamespace,
Subsystem: common.MetricsSubsystem,
Name: "buffer_writer_total_write_size_bytes",
Help: "Total size of data written by the BufferWriter in bytes.",
Name: "buffer_writer_write_size_bytes",
Help: "Size of data written by the BufferWriter in bytes.",
Buckets: prometheus.ExponentialBuckets(100, 10, 7),
})

totalWriteDuration = promauto.NewCounter(prometheus.CounterOpts{
Expand Down

0 comments on commit 97599b1

Please sign in to comment.