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
Boxiang Sun
gitlab-ce
Commits
19634c25
Commit
19634c25
authored
Sep 07, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup metrics names and removing unnecessary cache read total
parent
c361c1e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
30 deletions
+8
-30
lib/gitlab/metrics/subscribers/rails_cache.rb
lib/gitlab/metrics/subscribers/rails_cache.rb
+5
-15
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
+3
-15
No files found.
lib/gitlab/metrics/subscribers/rails_cache.rb
View file @
19634c25
...
...
@@ -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_mis
s_total
.
increment
(
current_transaction
.
labels
)
self
.
class
.
metric_cache_
misse
s_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_mis
s_total
.
increment
(
current_transaction
.
labels
)
self
.
class
.
metric_cache_
misse
s_total
.
increment
(
current_transaction
.
labels
)
current_transaction
.
increment
(
:cache_read_miss_count
,
1
)
end
...
...
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
View file @
19634c25
...
...
@@ -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_mis
s_total
).
to
receive
(
:increment
).
with
({})
expect
(
described_class
.
metric_cache_
misse
s_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_mis
s_total
).
not_to
receive
(
:increment
).
with
({})
expect
(
described_class
.
metric_cache_
misse
s_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_mis
s_total
).
to
receive
(
:increment
).
with
({})
expect
(
described_class
.
metric_cache_
misse
s_total
).
to
receive
(
:increment
).
with
({})
subscriber
.
cache_generate
(
event
)
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