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

[metrics] add maximum disk size as metric #704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
9 changes: 9 additions & 0 deletions cache/disk/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type SizedLRU struct {

onEvict EvictCallback

gaugeCacheMaxSizeBytes prometheus.Gauge
gaugeCacheSizeBytes prometheus.Gauge
gaugeCacheLogicalBytes prometheus.Gauge
counterEvictedBytes prometheus.Counter
Expand All @@ -67,6 +68,10 @@ func NewSizedLRU(maxSize int64, onEvict EvictCallback, initialCapacity int) Size
cache: make(map[interface{}]*list.Element, initialCapacity),
onEvict: onEvict,

gaugeCacheMaxSizeBytes: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "bazel_remote_disk_cache_max_size_bytes",
Help: "The maximum number of bytes in the disk backend",
}),
gaugeCacheSizeBytes: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "bazel_remote_disk_cache_size_bytes",
Help: "The current number of bytes in the disk backend",
Expand All @@ -87,10 +92,14 @@ func NewSizedLRU(maxSize int64, onEvict EvictCallback, initialCapacity int) Size
}

func (c *SizedLRU) RegisterMetrics() {
prometheus.MustRegister(c.gaugeCacheMaxSizeBytes)
prometheus.MustRegister(c.gaugeCacheSizeBytes)
prometheus.MustRegister(c.gaugeCacheLogicalBytes)
prometheus.MustRegister(c.counterEvictedBytes)
prometheus.MustRegister(c.counterOverwrittenBytes)

// This value never changes, set it now
c.gaugeCacheMaxSizeBytes.Set(float64(c.maxSize))
}

// Add adds a (key, value) to the cache, evicting items as necessary.
Expand Down