summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-09-07 22:59:27 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-11-02 18:11:44 +0100
commit19634c259da768700c1d6382c097fed7ef98fdca (patch)
treebaa5265f9d1d9369138d904e55e6a817d652a264
parentc361c1e857fe165e7a838aea1ecf7a10982cdbe0 (diff)
downloadgitlab-ce-19634c259da768700c1d6382c097fed7ef98fdca.tar.gz
Cleanup metrics names and removing unnecessary cache read total
-rw-r--r--lib/gitlab/metrics/subscribers/rails_cache.rb20
-rw-r--r--spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb18
2 files changed, 8 insertions, 30 deletions
diff --git a/lib/gitlab/metrics/subscribers/rails_cache.rb b/lib/gitlab/metrics/subscribers/rails_cache.rb
index 17814f6b845..da5bf208e74 100644
--- a/lib/gitlab/metrics/subscribers/rails_cache.rb
+++ b/lib/gitlab/metrics/subscribers/rails_cache.rb
@@ -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
diff --git a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
index b07b791b06a..453a93d90ac 100644
--- a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
+++ b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
@@ -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