Commit 36b70d9c authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bvl-remove-ancestor-cache-counter' into 'master'

Remove the repository_ancestor_calls_total counter

Closes #37771

See merge request gitlab-org/gitlab!23878
parents 47e09db7 06a07df6
...@@ -927,22 +927,12 @@ class Repository ...@@ -927,22 +927,12 @@ class Repository
def ancestor?(ancestor_id, descendant_id) def ancestor?(ancestor_id, descendant_id)
return false if ancestor_id.nil? || descendant_id.nil? return false if ancestor_id.nil? || descendant_id.nil?
counter = Gitlab::Metrics.counter(
:repository_ancestor_calls_total,
'The number of times we call Repository#ancestor with valid arguments')
cache_hit = true
cache_key = "ancestor:#{ancestor_id}:#{descendant_id}" cache_key = "ancestor:#{ancestor_id}:#{descendant_id}"
result = request_store_cache.fetch(cache_key) do request_store_cache.fetch(cache_key) do
cache.fetch(cache_key) do cache.fetch(cache_key) do
cache_hit = false
raw_repository.ancestor?(ancestor_id, descendant_id) raw_repository.ancestor?(ancestor_id, descendant_id)
end end
end end
counter.increment(cache_hit: cache_hit.to_s)
result
end end
def fetch_as_mirror(url, forced: false, refmap: :all_refs, remote_name: nil, prune: true) def fetch_as_mirror(url, forced: false, refmap: :all_refs, remote_name: nil, prune: true)
......
...@@ -2450,15 +2450,6 @@ describe Repository do ...@@ -2450,15 +2450,6 @@ describe Repository do
2.times { repository.ancestor?(commit.id, ancestor.id) } 2.times { repository.ancestor?(commit.id, ancestor.id) }
end end
it 'increments a counter with cache hits' do
counter = Gitlab::Metrics.counter(:repository_ancestor_calls_total, 'Repository ancestor calls')
expect do
2.times { repository.ancestor?(commit.id, ancestor.id) }
end.to change { counter.get(cache_hit: 'true') }.by(1)
.and change { counter.get(cache_hit: 'false') }.by(1)
end
it 'returns the value from the request store' do it 'returns the value from the request store' do
repository.__send__(:request_store_cache).write(cache_key, "it's apparent") repository.__send__(:request_store_cache).write(cache_key, "it's apparent")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment