Merge branch 'add-cache-count-metrics' into 'master'
Add cache count metrics to rails cache See merge request !4157
This commit is contained in:
commit
78a67fc48d
3 changed files with 19 additions and 10 deletions
|
@ -51,6 +51,7 @@ v 8.8.0 (unreleased)
|
||||||
- Add API endpoints for un/subscribing from/to a label. !4051 (Ahmad Sherif)
|
- 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
|
- Hide left sidebar on phone screens to give more space for content
|
||||||
- Redesign navigation for profile and group pages
|
- Redesign navigation for profile and group pages
|
||||||
|
- Add counter metrics for rails cache
|
||||||
|
|
||||||
v 8.7.5
|
v 8.7.5
|
||||||
- Fix relative links in wiki pages. !4050
|
- Fix relative links in wiki pages. !4050
|
||||||
|
|
|
@ -6,26 +6,28 @@ module Gitlab
|
||||||
attach_to :active_support
|
attach_to :active_support
|
||||||
|
|
||||||
def cache_read(event)
|
def cache_read(event)
|
||||||
increment(:cache_read_duration, event.duration)
|
increment(:cache_read, event.duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_write(event)
|
def cache_write(event)
|
||||||
increment(:cache_write_duration, event.duration)
|
increment(:cache_write, event.duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_delete(event)
|
def cache_delete(event)
|
||||||
increment(:cache_delete_duration, event.duration)
|
increment(:cache_delete, event.duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_exist?(event)
|
def cache_exist?(event)
|
||||||
increment(:cache_exists_duration, event.duration)
|
increment(:cache_exists, event.duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
def increment(key, duration)
|
def increment(key, duration)
|
||||||
return unless current_transaction
|
return unless current_transaction
|
||||||
|
|
||||||
current_transaction.increment(:cache_duration, duration)
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
|
||||||
describe '#cache_read' do
|
describe '#cache_read' do
|
||||||
it 'increments the cache_read duration' do
|
it 'increments the cache_read duration' do
|
||||||
expect(subscriber).to receive(:increment).
|
expect(subscriber).to receive(:increment).
|
||||||
with(:cache_read_duration, event.duration)
|
with(:cache_read, event.duration)
|
||||||
|
|
||||||
subscriber.cache_read(event)
|
subscriber.cache_read(event)
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
|
||||||
describe '#cache_write' do
|
describe '#cache_write' do
|
||||||
it 'increments the cache_write duration' do
|
it 'increments the cache_write duration' do
|
||||||
expect(subscriber).to receive(:increment).
|
expect(subscriber).to receive(:increment).
|
||||||
with(:cache_write_duration, event.duration)
|
with(:cache_write, event.duration)
|
||||||
|
|
||||||
subscriber.cache_write(event)
|
subscriber.cache_write(event)
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
|
||||||
describe '#cache_delete' do
|
describe '#cache_delete' do
|
||||||
it 'increments the cache_delete duration' do
|
it 'increments the cache_delete duration' do
|
||||||
expect(subscriber).to receive(:increment).
|
expect(subscriber).to receive(:increment).
|
||||||
with(:cache_delete_duration, event.duration)
|
with(:cache_delete, event.duration)
|
||||||
|
|
||||||
subscriber.cache_delete(event)
|
subscriber.cache_delete(event)
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
|
||||||
describe '#cache_exist?' do
|
describe '#cache_exist?' do
|
||||||
it 'increments the cache_exists duration' do
|
it 'increments the cache_exists duration' do
|
||||||
expect(subscriber).to receive(:increment).
|
expect(subscriber).to receive(:increment).
|
||||||
with(:cache_exists_duration, event.duration)
|
with(:cache_exists, event.duration)
|
||||||
|
|
||||||
subscriber.cache_exist?(event)
|
subscriber.cache_exist?(event)
|
||||||
end
|
end
|
||||||
|
@ -61,10 +61,16 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
|
||||||
expect(transaction).to receive(:increment).
|
expect(transaction).to receive(:increment).
|
||||||
with(:cache_duration, event.duration)
|
with(:cache_duration, event.duration)
|
||||||
|
|
||||||
|
expect(transaction).to receive(:increment).
|
||||||
|
with(:cache_count, 1)
|
||||||
|
|
||||||
expect(transaction).to receive(:increment).
|
expect(transaction).to receive(:increment).
|
||||||
with(:cache_delete_duration, event.duration)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue