Skip to content

Commit

Permalink
removing old metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Protasio <[email protected]>
  • Loading branch information
alanprot committed Sep 7, 2023
1 parent d6ef1f2 commit f32ab11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
23 changes: 4 additions & 19 deletions pkg/storegateway/chunk_bytes_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ type chunkBytesPool struct {
pool *pool.BucketedBytes

// Metrics.
requestedBytes prometheus.Counter
returnedBytes prometheus.Counter

poolByteStats *prometheus.CounterVec
}

Expand All @@ -24,14 +21,6 @@ func newChunkBytesPool(minBucketSize, maxBucketSize int, maxChunkPoolBytes uint6

return &chunkBytesPool{
pool: upstream,
requestedBytes: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "cortex_bucket_store_chunk_pool_requested_bytes_total",
Help: "Total bytes requested to chunk bytes pool.",
}),
returnedBytes: promauto.With(reg).NewCounter(prometheus.CounterOpts{
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",
Help: "Total bytes polled by the chunk bytes pool by operation.",
Expand All @@ -45,18 +34,14 @@ func (p *chunkBytesPool) Get(sz int) (*[]byte, error) {
return buffer, err
}

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)))
p.poolByteStats.WithLabelValues("Get", "cap").Add(float64(cap(*buffer)))
p.poolByteStats.WithLabelValues("Get", "Requested").Add(float64(sz))
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.poolByteStats.WithLabelValues("Put", "Len").Add(float64(len(*b)))
p.poolByteStats.WithLabelValues("Put", "Cap").Add(float64(cap(*b)))
p.pool.Put(b)
}
23 changes: 13 additions & 10 deletions pkg/storegateway/chunk_bytes_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ func TestChunkBytesPool_Get(t *testing.T) {
reg := prometheus.NewPedanticRegistry()
p, err := newChunkBytesPool(cortex_tsdb.ChunkPoolDefaultMinBucketSize, cortex_tsdb.ChunkPoolDefaultMaxBucketSize, 0, reg)
require.NoError(t, err)

testBytes := []byte("test")
_, err = p.Get(store.EstimatedMaxChunkSize - 1)
require.NoError(t, err)

_, err = p.Get(store.EstimatedMaxChunkSize + 1)
b, err := p.Get(store.EstimatedMaxChunkSize + 1)
require.NoError(t, err)

*b = append(*b, testBytes...)

p.Put(b)

assert.NoError(t, testutil.GatherAndCompare(reg, bytes.NewBufferString(fmt.Sprintf(`
# HELP cortex_bucket_store_chunk_pool_requested_bytes_total Total bytes requested to chunk bytes pool.
# TYPE cortex_bucket_store_chunk_pool_requested_bytes_total counter
cortex_bucket_store_chunk_pool_requested_bytes_total %d
# HELP cortex_bucket_store_chunk_pool_returned_bytes_total Total bytes returned by the chunk bytes pool.
# TYPE cortex_bucket_store_chunk_pool_returned_bytes_total counter
cortex_bucket_store_chunk_pool_returned_bytes_total %d
`, store.EstimatedMaxChunkSize*2, store.EstimatedMaxChunkSize*3))))
# HELP cortex_bucket_store_chunk_pool_bytes_total Total bytes polled by the chunk bytes pool by operation.
# TYPE cortex_bucket_store_chunk_pool_bytes_total counter
cortex_bucket_store_chunk_pool_bytes_total{operation="Get",stats="Cap"} %d
cortex_bucket_store_chunk_pool_bytes_total{operation="Get",stats="Requested"} %d
cortex_bucket_store_chunk_pool_bytes_total{operation="Put",stats="Cap"} %d
cortex_bucket_store_chunk_pool_bytes_total{operation="Put",stats="Len"} %d
`, store.EstimatedMaxChunkSize*3, store.EstimatedMaxChunkSize*2, store.EstimatedMaxChunkSize*2, len(testBytes)))))
}

0 comments on commit f32ab11

Please sign in to comment.