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
Léo-Paul Géneau
gitlab-ce
Commits
330de255
Commit
330de255
authored
Jun 29, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RailsCache metrics now includes fetch_hit/fetch_miss and read_hit/read_miss info.
parent
e9a4d117
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
2 deletions
+116
-2
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/metrics/subscribers/rails_cache.rb
lib/gitlab/metrics/subscribers/rails_cache.rb
+12
-2
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
+103
-0
No files found.
CHANGELOG
View file @
330de255
...
@@ -30,6 +30,7 @@ v 8.10.0 (unreleased)
...
@@ -30,6 +30,7 @@ v 8.10.0 (unreleased)
- Add API endpoint for a group issues !4520 (mahcsig)
- Add API endpoint for a group issues !4520 (mahcsig)
- Add Bugzilla integration !4930 (iamtjg)
- Add Bugzilla integration !4930 (iamtjg)
- Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
- Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
- RailsCache metris now includes fetch_hit/fetch_miss and read_hit/read_miss info.
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
- Add basic system information like memory and disk usage to the admin panel
- Add basic system information like memory and disk usage to the admin panel
- Don't garbage collect commits that have related DB records like comments
- Don't garbage collect commits that have related DB records like comments
...
...
lib/gitlab/metrics/subscribers/rails_cache.rb
View file @
330de255
...
@@ -2,11 +2,21 @@ module Gitlab
...
@@ -2,11 +2,21 @@ module Gitlab
module
Metrics
module
Metrics
module
Subscribers
module
Subscribers
# Class for tracking the total time spent in Rails cache calls
# Class for tracking the total time spent in Rails cache calls
# http://guides.rubyonrails.org/active_support_instrumentation.html
class
RailsCache
<
ActiveSupport
::
Subscriber
class
RailsCache
<
ActiveSupport
::
Subscriber
attach_to
:active_support
attach_to
:active_support
def
cache_read
(
event
)
def
cache_read
(
event
)
increment
(
:cache_read
,
event
.
duration
)
increment
(
:cache_read
,
event
.
duration
)
return
unless
current_transaction
return
if
event
.
payload
[
:super_operation
]
==
:fetch
if
event
.
payload
[
:hit
]
current_transaction
.
increment
(
:cache_read_hit_count
,
1
)
else
current_transaction
.
increment
(
:cache_read_miss_count
,
1
)
end
end
end
def
cache_write
(
event
)
def
cache_write
(
event
)
...
@@ -24,13 +34,13 @@ module Gitlab
...
@@ -24,13 +34,13 @@ module Gitlab
def
cache_fetch_hit
(
event
)
def
cache_fetch_hit
(
event
)
return
unless
current_transaction
return
unless
current_transaction
current_transaction
.
increment
(
:cache_
fetch_hi
t
,
1
)
current_transaction
.
increment
(
:cache_
read_hit_coun
t
,
1
)
end
end
def
cache_generate
(
event
)
def
cache_generate
(
event
)
return
unless
current_transaction
return
unless
current_transaction
current_transaction
.
increment
(
:cache_
fetch_miss
,
1
)
current_transaction
.
increment
(
:cache_
read_miss_count
,
1
)
end
end
def
increment
(
key
,
duration
)
def
increment
(
key
,
duration
)
...
...
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
View file @
330de255
...
@@ -13,6 +13,61 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
...
@@ -13,6 +13,61 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
subscriber
.
cache_read
(
event
)
subscriber
.
cache_read
(
event
)
end
end
context
'with a transaction'
do
before
do
allow
(
subscriber
).
to
receive
(
:current_transaction
).
and_return
(
transaction
)
end
context
'with hit event'
do
let
(
:event
)
{
double
(
:event
,
duration:
15.2
,
payload:
{
hit:
true
})
}
it
'increments the cache_read_hit count'
do
expect
(
transaction
).
to
receive
(
:increment
).
with
(
:cache_read_hit_count
,
1
)
expect
(
transaction
).
to
receive
(
:increment
).
with
(
any_args
).
at_least
(
1
)
# Other calls
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
})
}
it
'does not increment cache read miss'
do
expect
(
transaction
).
not_to
receive
(
:increment
).
with
(
:cache_read_hit_count
,
1
)
subscriber
.
cache_read
(
event
)
end
end
end
context
'with miss event'
do
let
(
:event
)
{
double
(
:event
,
duration:
15.2
,
payload:
{
hit:
false
})
}
it
'increments the cache_read_miss count'
do
expect
(
transaction
).
to
receive
(
:increment
).
with
(
:cache_read_miss_count
,
1
)
expect
(
transaction
).
to
receive
(
:increment
).
with
(
any_args
).
at_least
(
1
)
# Other calls
subscriber
.
cache_read
(
event
)
end
context
'when super operation is fetch'
do
let
(
:event
)
{
double
(
:event
,
duration:
15.2
,
payload:
{
hit:
false
,
super_operation: :fetch
})
}
it
'does not increment cache read miss'
do
expect
(
transaction
).
not_to
receive
(
:increment
).
with
(
:cache_read_miss_count
,
1
)
subscriber
.
cache_read
(
event
)
end
end
end
end
end
end
describe
'#cache_write'
do
describe
'#cache_write'
do
...
@@ -42,6 +97,54 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
...
@@ -42,6 +97,54 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
end
end
end
describe
'#cache_fetch_hit'
do
context
'without a transaction'
do
it
'returns'
do
expect
(
transaction
).
not_to
receive
(
:increment
)
subscriber
.
cache_fetch_hit
(
event
)
end
end
context
'with a transaction'
do
before
do
allow
(
subscriber
).
to
receive
(
:current_transaction
).
and_return
(
transaction
)
end
it
'increments the cache_read_hit count'
do
expect
(
transaction
).
to
receive
(
:increment
).
with
(
:cache_read_hit_count
,
1
)
subscriber
.
cache_fetch_hit
(
event
)
end
end
end
describe
'#cache_generate'
do
context
'without a transaction'
do
it
'returns'
do
expect
(
transaction
).
not_to
receive
(
:increment
)
subscriber
.
cache_generate
(
event
)
end
end
context
'with a transaction'
do
before
do
allow
(
subscriber
).
to
receive
(
:current_transaction
).
and_return
(
transaction
)
end
it
'increments the cache_fetch_miss count'
do
expect
(
transaction
).
to
receive
(
:increment
).
with
(
:cache_read_miss_count
,
1
)
subscriber
.
cache_generate
(
event
)
end
end
end
describe
'#increment'
do
describe
'#increment'
do
context
'without a transaction'
do
context
'without a transaction'
do
it
'returns'
do
it
'returns'
do
...
...
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