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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
67b3e3d8
Commit
67b3e3d8
authored
Oct 24, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move metrics for ActiveRecord, RailsCache and queue duration to instance variables
parent
735365a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
38 deletions
+40
-38
lib/gitlab/metrics/subscribers/active_record.rb
lib/gitlab/metrics/subscribers/active_record.rb
+10
-10
lib/gitlab/metrics/subscribers/rails_cache.rb
lib/gitlab/metrics/subscribers/rails_cache.rb
+20
-20
lib/gitlab/middleware/rails_queue_duration.rb
lib/gitlab/middleware/rails_queue_duration.rb
+10
-8
No files found.
lib/gitlab/metrics/subscribers/active_record.rb
View file @
67b3e3d8
...
...
@@ -5,18 +5,9 @@ module Gitlab
class
ActiveRecord
<
ActiveSupport
::
Subscriber
attach_to
:active_record
def
self
.
metric_sql_duration_seconds
@metric_sql_duration_seconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_sql_duration_seconds
,
'SQL time'
,
Transaction
::
BASE_LABELS
,
[
0.001
,
0.002
,
0.005
,
0.01
,
0.02
,
0.05
,
0.1
,
0.500
,
2.0
,
10.0
]
)
end
def
sql
(
event
)
return
unless
current_transaction
self
.
class
.
metric_sql_duration_seconds
.
observe
(
current_transaction
.
labels
,
event
.
duration
/
1000.0
)
metric_sql_duration_seconds
.
observe
(
current_transaction
.
labels
,
event
.
duration
/
1000.0
)
current_transaction
.
increment
(
:sql_duration
,
event
.
duration
,
false
)
current_transaction
.
increment
(
:sql_count
,
1
,
false
)
...
...
@@ -27,6 +18,15 @@ module Gitlab
def
current_transaction
Transaction
.
current
end
def
metric_sql_duration_seconds
@metric_sql_duration_seconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_sql_duration_seconds
,
'SQL time'
,
Transaction
::
BASE_LABELS
,
[
0.001
,
0.002
,
0.005
,
0.01
,
0.02
,
0.05
,
0.1
,
0.500
,
2.0
,
10.0
]
)
end
end
end
end
...
...
lib/gitlab/metrics/subscribers/rails_cache.rb
View file @
67b3e3d8
...
...
@@ -6,23 +6,6 @@ module Gitlab
class
RailsCache
<
ActiveSupport
::
Subscriber
attach_to
:active_support
def
self
.
metric_cache_operation_duration_seconds
@metric_cache_operation_duration_seconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_cache_operation_duration_seconds
,
'Cache access time'
,
Transaction
::
BASE_LABELS
.
merge
({
action:
nil
}),
[
0.001
,
0.002
,
0.005
,
0.01
,
0.02
,
0.05
,
0.1
,
0.500
,
2.0
,
10.0
]
)
end
def
self
.
metric_cache_misses_total
@metric_cache_misses_total
||=
Gitlab
::
Metrics
.
counter
(
:gitlab_cache_misses_total
,
'Cache read miss'
,
Transaction
::
BASE_LABELS
)
end
def
cache_read
(
event
)
observe
(
:read
,
event
.
duration
)
...
...
@@ -32,7 +15,7 @@ module Gitlab
if
event
.
payload
[
:hit
]
current_transaction
.
increment
(
:cache_read_hit_count
,
1
,
false
)
else
self
.
class
.
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
self
.
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
current_transaction
.
increment
(
:cache_read_miss_count
,
1
,
false
)
end
end
...
...
@@ -58,14 +41,14 @@ module Gitlab
def
cache_generate
(
event
)
return
unless
current_transaction
self
.
class
.
metric_cache_misses_total
.
increment
(
current_transaction
.
labels
)
self
.
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
.
class
.
metric_cache_operation_duration_seconds
.
observe
(
current_transaction
.
labels
.
merge
({
operation:
key
}),
duration
/
1000.0
)
self
.
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
)
...
...
@@ -77,6 +60,23 @@ module Gitlab
def
current_transaction
Transaction
.
current
end
def
metric_cache_operation_duration_seconds
@metric_cache_operation_duration_seconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_cache_operation_duration_seconds
,
'Cache access time'
,
Transaction
::
BASE_LABELS
.
merge
({
action:
nil
}),
[
0.001
,
0.002
,
0.005
,
0.01
,
0.02
,
0.05
,
0.1
,
0.500
,
2.0
,
10.0
]
)
end
def
metric_cache_misses_total
@metric_cache_misses_total
||=
Gitlab
::
Metrics
.
counter
(
:gitlab_cache_misses_total
,
'Cache read miss'
,
Transaction
::
BASE_LABELS
)
end
end
end
end
...
...
lib/gitlab/middleware/rails_queue_duration.rb
View file @
67b3e3d8
...
...
@@ -5,13 +5,6 @@
module
Gitlab
module
Middleware
class
RailsQueueDuration
def
self
.
metric_rails_queue_duration_seconds
@metric_rails_queue_duration_seconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_rails_queue_duration_seconds
,
Gitlab
::
Metrics
::
Transaction
::
BASE_LABELS
)
end
def
initialize
(
app
)
@app
=
app
end
...
...
@@ -23,11 +16,20 @@ module Gitlab
# Time in milliseconds since gitlab-workhorse started the request
duration
=
Time
.
now
.
to_f
*
1_000
-
proxy_start
.
to_f
/
1_000_000
trans
.
set
(
:rails_queue_duration
,
duration
)
self
.
class
.
metric_rails_queue_duration_seconds
.
observe
(
trans
.
labels
,
duration
/
1_000
)
metric_rails_queue_duration_seconds
.
observe
(
trans
.
labels
,
duration
/
1_000
)
end
@app
.
call
(
env
)
end
private
def
metric_rails_queue_duration_seconds
@metric_rails_queue_duration_seconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_rails_queue_duration_seconds
,
Gitlab
::
Metrics
::
Transaction
::
BASE_LABELS
)
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