Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
78a67fc4
Commit
78a67fc4
authored
May 16, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'add-cache-count-metrics' into 'master'
Add cache count metrics to rails cache See merge request !4157
parents
c3f68b10
b9306c2e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
10 deletions
+19
-10
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/metrics/subscribers/rails_cache.rb
lib/gitlab/metrics/subscribers/rails_cache.rb
+7
-5
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
+11
-5
No files found.
CHANGELOG
View file @
78a67fc4
...
@@ -51,6 +51,7 @@ v 8.8.0 (unreleased)
...
@@ -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
...
...
lib/gitlab/metrics/subscribers/rails_cache.rb
View file @
78a67fc4
...
@@ -6,26 +6,28 @@ module Gitlab
...
@@ -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
...
...
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
View file @
78a67fc4
...
@@ -9,7 +9,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment