Commit 78a67fc4 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'add-cache-count-metrics' into 'master'

Add cache count metrics to rails cache

See merge request !4157
parents c3f68b10 b9306c2e
......@@ -51,6 +51,7 @@ v 8.8.0 (unreleased)
- Add API endpoints for un/subscribing from/to a label. !4051 (Ahmad Sherif)
- Hide left sidebar on phone screens to give more space for content
- Redesign navigation for profile and group pages
- Add counter metrics for rails cache
v 8.7.5
- Fix relative links in wiki pages. !4050
......
......@@ -6,26 +6,28 @@ module Gitlab
attach_to :active_support
def cache_read(event)
increment(:cache_read_duration, event.duration)
increment(:cache_read, event.duration)
end
def cache_write(event)
increment(:cache_write_duration, event.duration)
increment(:cache_write, event.duration)
end
def cache_delete(event)
increment(:cache_delete_duration, event.duration)
increment(:cache_delete, event.duration)
end
def cache_exist?(event)
increment(:cache_exists_duration, event.duration)
increment(:cache_exists, event.duration)
end
def increment(key, duration)
return unless current_transaction
current_transaction.increment(:cache_duration, duration)
current_transaction.increment(key, duration)
current_transaction.increment(:cache_count, 1)
current_transaction.increment("#{key}_duration".to_sym, duration)
current_transaction.increment("#{key}_count".to_sym, 1)
end
private
......
......@@ -9,7 +9,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
describe '#cache_read' do
it 'increments the cache_read duration' do
expect(subscriber).to receive(:increment).
with(:cache_read_duration, event.duration)
with(:cache_read, event.duration)
subscriber.cache_read(event)
end
......@@ -18,7 +18,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
describe '#cache_write' do
it 'increments the cache_write duration' do
expect(subscriber).to receive(:increment).
with(:cache_write_duration, event.duration)
with(:cache_write, event.duration)
subscriber.cache_write(event)
end
......@@ -27,7 +27,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
describe '#cache_delete' do
it 'increments the cache_delete duration' do
expect(subscriber).to receive(:increment).
with(:cache_delete_duration, event.duration)
with(:cache_delete, event.duration)
subscriber.cache_delete(event)
end
......@@ -36,7 +36,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
describe '#cache_exist?' do
it 'increments the cache_exists duration' do
expect(subscriber).to receive(:increment).
with(:cache_exists_duration, event.duration)
with(:cache_exists, event.duration)
subscriber.cache_exist?(event)
end
......@@ -61,10 +61,16 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
expect(transaction).to receive(:increment).
with(:cache_duration, event.duration)
expect(transaction).to receive(:increment).
with(:cache_count, 1)
expect(transaction).to receive(:increment).
with(:cache_delete_duration, event.duration)
subscriber.increment(:cache_delete_duration, event.duration)
expect(transaction).to receive(:increment).
with(:cache_delete_count, 1)
subscriber.increment(:cache_delete, event.duration)
end
end
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