BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c9f0070b
Commit
c9f0070b
authored
Oct 24, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make subscriber tests pass, after refactoring metrics
parent
a300787f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
11 deletions
+11
-11
action_view.rb
lib/gitlab/metrics/subscribers/action_view.rb
+1
-1
rails_cache.rb
lib/gitlab/metrics/subscribers/rails_cache.rb
+3
-3
action_view_spec.rb
spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
+1
-1
active_record_spec.rb
spec/lib/gitlab/metrics/subscribers/active_record_spec.rb
+1
-1
rails_cache_spec.rb
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
+4
-4
rails_queue_duration_spec.rb
spec/lib/gitlab/middleware/rails_queue_duration_spec.rb
+1
-1
No files found.
lib/gitlab/metrics/subscribers/action_view.rb
View file @
c9f0070b
...
...
@@ -28,7 +28,7 @@ module Gitlab
values
=
values_for
(
event
)
tags
=
tags_for
(
event
)
self
.
metric_view_rendering_duration_seconds
.
observe
(
metric_view_rendering_duration_seconds
.
observe
(
current_transaction
.
labels
.
merge
(
tags
),
event
.
duration
)
...
...
lib/gitlab/metrics/subscribers/rails_cache.rb
View file @
c9f0070b
...
...
@@ -15,7 +15,7 @@ module Gitlab
if
event
.
payload
[
:hit
]
current_transaction
.
increment
(
:cache_read_hit_count
,
1
,
false
)
else
self
.
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
current_transaction
.
increment
(
:cache_read_miss_count
,
1
,
false
)
end
end
...
...
@@ -41,14 +41,14 @@ module Gitlab
def
cache_generate
(
event
)
return
unless
current_transaction
self
.
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
current_transaction
.
increment
(
:cache_read_miss_count
,
1
)
end
def
observe
(
key
,
duration
)
return
unless
current_transaction
self
.
metric_cache_operation_duration_seconds
.
observe
(
current_transaction
.
labels
.
merge
({
operation:
key
}),
duration
/
1000.0
)
metric_cache_operation_duration_seconds
.
observe
(
current_transaction
.
labels
.
merge
({
operation:
key
}),
duration
/
1000.0
)
current_transaction
.
increment
(
:cache_duration
,
duration
,
false
)
current_transaction
.
increment
(
:cache_count
,
1
,
false
)
current_transaction
.
increment
(
"cache_
#{
key
}
_duration"
.
to_sym
,
duration
,
false
)
...
...
spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
View file @
c9f0070b
...
...
@@ -32,7 +32,7 @@ describe Gitlab::Metrics::Subscribers::ActionView do
end
it
'observes view rendering time'
do
expect
(
described_class
.
metric_view_rendering_duration_seconds
)
expect
(
subscriber
.
send
(
:metric_view_rendering_duration_seconds
)
)
.
to
receive
(
:observe
)
.
with
({
view:
'app/views/x.html.haml'
},
2.1
)
...
...
spec/lib/gitlab/metrics/subscribers/active_record_spec.rb
View file @
c9f0070b
...
...
@@ -25,7 +25,7 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
expect
(
subscriber
).
to
receive
(
:current_transaction
)
.
at_least
(
:once
)
.
and_return
(
transaction
)
expect
(
described_class
.
metric_sql_duration_seconds
).
to
receive
(
:observe
).
with
({},
0.002
)
expect
(
subscriber
.
send
(
:metric_sql_duration_seconds
)
).
to
receive
(
:observe
).
with
({},
0.002
)
subscriber
.
sql
(
event
)
end
...
...
spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
View file @
c9f0070b
...
...
@@ -58,7 +58,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it
'increments the cache_read_miss total'
do
expect
(
described_class
.
metric_cache_misses_total
).
to
receive
(
:increment
).
with
({})
expect
(
subscriber
.
send
(
:metric_cache_misses_total
)
).
to
receive
(
:increment
).
with
({})
subscriber
.
cache_read
(
event
)
end
...
...
@@ -74,7 +74,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it
'does not increment cache_read_miss total'
do
expect
(
described_class
.
metric_cache_misses_total
).
not_to
receive
(
:increment
).
with
({})
expect
(
subscriber
.
send
(
:metric_cache_misses_total
)
).
not_to
receive
(
:increment
).
with
({})
subscriber
.
cache_read
(
event
)
end
...
...
@@ -157,7 +157,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it
'increments the cache_read_miss total'
do
expect
(
described_class
.
metric_cache_misses_total
).
to
receive
(
:increment
).
with
({})
expect
(
subscriber
.
send
(
:metric_cache_misses_total
)
).
to
receive
(
:increment
).
with
({})
subscriber
.
cache_generate
(
event
)
end
...
...
@@ -196,7 +196,7 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
it
'observes cache metric'
do
expect
(
described_class
.
metric_cache_operation_duration_seconds
)
expect
(
subscriber
.
send
(
:metric_cache_operation_duration_seconds
)
)
.
to
receive
(
:observe
)
.
with
(
transaction
.
labels
.
merge
(
operation: :delete
),
event
.
duration
/
1000.0
)
...
...
spec/lib/gitlab/middleware/rails_queue_duration_spec.rb
View file @
c9f0070b
...
...
@@ -34,7 +34,7 @@ describe Gitlab::Middleware::RailsQueueDuration do
it
'observes rails queue duration metrics and calls the app when the header is present'
do
env
[
'HTTP_GITLAB_WORKHORSE_PROXY_START'
]
=
'2000000000'
expect
(
described_class
.
metric_rails_queue_duration_seconds
).
to
receive
(
:observe
).
with
(
transaction
.
labels
,
1
)
expect
(
middleware
.
send
(
:metric_rails_queue_duration_seconds
)
).
to
receive
(
:observe
).
with
(
transaction
.
labels
,
1
)
Timecop
.
freeze
(
Time
.
at
(
3
))
do
expect
(
middleware
.
call
(
env
)).
to
eq
(
'yay'
)
...
...
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