Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating new metric around chunks bytespool #5552

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/storegateway/chunk_bytes_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type chunkBytesPool struct {
// Metrics.
requestedBytes prometheus.Counter
returnedBytes prometheus.Counter

poolByteStats *prometheus.CounterVec
}

func newChunkBytesPool(minBucketSize, maxBucketSize int, maxChunkPoolBytes uint64, reg prometheus.Registerer) (*chunkBytesPool, error) {
Expand All @@ -30,6 +32,10 @@ func newChunkBytesPool(minBucketSize, maxBucketSize int, maxChunkPoolBytes uint6
Name: "cortex_bucket_store_chunk_pool_returned_bytes_total",
Help: "Total bytes returned by the chunk bytes pool.",
}),
poolByteStats: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "cortex_bucket_store_chunk_pool_bytes_total",
alanprot marked this conversation as resolved.
Show resolved Hide resolved
Help: "Total bytes polled by the chunk bytes pool by operation.",
alanprot marked this conversation as resolved.
Show resolved Hide resolved
}, []string{"operation", "stats"}),
}, nil
}

Expand All @@ -42,9 +48,15 @@ func (p *chunkBytesPool) Get(sz int) (*[]byte, error) {
p.requestedBytes.Add(float64(sz))
p.returnedBytes.Add(float64(cap(*buffer)))

p.poolByteStats.WithLabelValues("Get", "requested").Add(float64(sz))
p.poolByteStats.WithLabelValues("Get", "len").Add(float64(len(*buffer)))
alanprot marked this conversation as resolved.
Show resolved Hide resolved
p.poolByteStats.WithLabelValues("Get", "cap").Add(float64(cap(*buffer)))

return buffer, err
}

func (p *chunkBytesPool) Put(b *[]byte) {
p.poolByteStats.WithLabelValues("Put", "len").Add(float64(len(*b)))
p.poolByteStats.WithLabelValues("Put", "cap").Add(float64(cap(*b)))
p.pool.Put(b)
}
Loading