Commit 19634c25 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Cleanup metrics names and removing unnecessary cache read total

parent c361c1e8
......@@ -15,17 +15,9 @@ module Gitlab
)
end
def self.metric_cache_read_hit_total
@metric_cache_read_hit_total ||= Gitlab::Metrics.counter(
:gitlab_cache_read_hit_total,
'Cache read hit',
Transaction::BASE_LABELS
)
end
def self.metric_cache_read_miss_total
@metric_cache_read_miss_total ||= Gitlab::Metrics.counter(
:gitlab_cache_read_miss_total,
def self.metric_cache_misses_total
@metric_cache_misses_total ||= Gitlab::Metrics.counter(
:gitlab_cache_misses_total,
'Cache read miss',
Transaction::BASE_LABELS
)
......@@ -38,10 +30,9 @@ module Gitlab
return if event.payload[:super_operation] == :fetch
if event.payload[:hit]
self.class.metric_cache_read_hit_total.increment(current_transaction.labels)
current_transaction.increment(:cache_read_hit_count, 1, false)
else
self.class.metric_cache_read_miss_total.increment(current_transaction.labels)
self.class.metric_cache_misses_total.increment(current_transaction.labels)
current_transaction.increment(:cache_read_miss_count, 1, false)
end
end
......@@ -61,14 +52,13 @@ module Gitlab
def cache_fetch_hit(event)
return unless current_transaction
self.class.metric_cache_read_hit_total.increment(current_transaction.labels)
current_transaction.increment(:cache_read_hit_count, 1)
end
def cache_generate(event)
return unless current_transaction
self.class.metric_cache_read_miss_total.increment(current_transaction.labels)
self.class.metric_cache_misses_total.increment(current_transaction.labels)
current_transaction.increment(:cache_read_miss_count, 1)
end
......
......@@ -33,12 +33,6 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
subscriber.cache_read(event)
end
it 'increments the cache_read_hit total' do
expect(described_class.metric_cache_read_hit_total).to receive(:increment)
subscriber.cache_read(event)
end
context 'when super operation is fetch' do
let(:event) { double(:event, duration: 15.2, payload: { hit: true, super_operation: :fetch }) }
......@@ -64,7 +58,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it 'increments the cache_read_miss total' do
expect(described_class.metric_cache_read_miss_total).to receive(:increment).with({})
expect(described_class.metric_cache_misses_total).to receive(:increment).with({})
subscriber.cache_read(event)
end
......@@ -80,7 +74,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it 'does not increment cache_read_miss total' do
expect(described_class.metric_cache_read_miss_total).not_to receive(:increment).with({})
expect(described_class.metric_cache_misses_total).not_to receive(:increment).with({})
subscriber.cache_read(event)
end
......@@ -137,12 +131,6 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
subscriber.cache_fetch_hit(event)
end
it 'increments the cache_read_hit total' do
expect(described_class.metric_cache_read_hit_total).to receive(:increment).with({})
subscriber.cache_fetch_hit(event)
end
end
end
......@@ -169,7 +157,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it 'increments the cache_read_miss total' do
expect(described_class.metric_cache_read_miss_total).to receive(:increment).with({})
expect(described_class.metric_cache_misses_total).to receive(:increment).with({})
subscriber.cache_generate(event)
end
......
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