Add metrics to the RepositoryCacheAdapter

To be able to appropriately size the new Redis cluster, we should have some idea of the traffic it would be serving. We should try to have the following in metrics:

  • repository_cache_read_bytes
  • repository_cache_write_bytes
  • repository_cache_read_count
  • repository_cache_write_count
  • repository_cache_hits_total
  • repository_cache_read_total

Ideally, we'd also able the read- and write-count with the actual redis command, but that might not be straightforward in all cases. Most of this uses an ActiveSupport::Cache::RedisCacheStore (Rails.cache). I'd consider this nice-to-have.

We have also enabled caching for everything that passes through this class. So we should make sure we get the real size (after compression) for the read- and write- bytes metrics.

There are 3 classes that are used from RepositoryCacheAdapter:

  • RepositoryCache: for most methods. This instance can have Rails.cache as a backend as well as Gitlab::SafeRequestStore. We only need data from the Rails.cache backend
  • RepositoryHashCache: This is always backed by Gitlab::Redis::Cache. This class already has some metrics being emitted. It stores values in Redis
  • RepositorySetCache: This is always backed by Gitlab::Redis::Cache.
Edited by Bob Van Landuyt