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
3cc28601
Commit
3cc28601
authored
Sep 05, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup sampling code and fix bug with samplers running without sleep
parent
b6d75b29
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
29 deletions
+20
-29
lib/gitlab/daemon.rb
lib/gitlab/daemon.rb
+1
-1
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+5
-18
lib/gitlab/metrics/samplers/base_sampler.rb
lib/gitlab/metrics/samplers/base_sampler.rb
+4
-0
lib/gitlab/metrics/samplers/ruby_sampler.rb
lib/gitlab/metrics/samplers/ruby_sampler.rb
+1
-1
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+9
-9
No files found.
lib/gitlab/daemon.rb
View file @
3cc28601
...
@@ -43,7 +43,7 @@ module Gitlab
...
@@ -43,7 +43,7 @@ module Gitlab
if
thread
if
thread
thread
.
wakeup
if
thread
.
alive?
thread
.
wakeup
if
thread
.
alive?
thread
.
join
thread
.
join
unless
Thread
.
current
==
thread
@thread
=
nil
@thread
=
nil
end
end
end
end
...
...
lib/gitlab/metrics/method_call.rb
View file @
3cc28601
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
def
self
.
call_real_duration_histogram
def
self
.
call_real_duration_histogram
@call_real_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_real_duration_milliseconds
,
@call_real_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_real_duration_milliseconds
,
'Method calls real duration'
,
'Method calls real duration'
,
{},
{
call_name:
nil
},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
])
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
])
end
end
...
@@ -18,17 +18,16 @@ module Gitlab
...
@@ -18,17 +18,16 @@ module Gitlab
def
self
.
call_cpu_duration_histogram
def
self
.
call_cpu_duration_histogram
@call_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_cpu_duration_milliseconds
,
@call_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_cpu_duration_milliseconds
,
'Method calls cpu duration'
,
'Method calls cpu duration'
,
{},
{
call_name:
nil
},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
])
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
])
end
end
def
initialize
(
name
,
tags
=
{}
)
def
initialize
(
name
)
@name
=
name
@name
=
name
@real_time
=
0
@real_time
=
0
@cpu_time
=
0
@cpu_time
=
0
@call_count
=
0
@call_count
=
0
@tags
=
tags
end
end
# Measures the real and CPU execution time of the supplied block.
# Measures the real and CPU execution time of the supplied block.
...
@@ -42,25 +41,13 @@ module Gitlab
...
@@ -42,25 +41,13 @@ module Gitlab
@call_count
+=
1
@call_count
+=
1
if
above_threshold?
if
above_threshold?
self
.
class
.
call_real_duration_histogram
.
observe
(
labels
,
@real_time
)
self
.
class
.
call_real_duration_histogram
.
observe
(
{
call_name:
@name
}
,
@real_time
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
labels
,
@cpu_time
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
{
call_name:
@name
}
,
@cpu_time
)
end
end
retval
retval
end
end
def
labels
@labels
||=
@tags
.
merge
(
source_label
).
merge
({
call_name:
@name
})
end
def
source_label
if
Sidekiq
.
server?
{
source:
'sidekiq'
}
else
{
source:
'rails'
}
end
end
# Returns a Metric instance of the current method call.
# Returns a Metric instance of the current method call.
def
to_metric
def
to_metric
Metric
.
new
(
Metric
.
new
(
...
...
lib/gitlab/metrics/samplers/base_sampler.rb
View file @
3cc28601
require
'logger'
require
'logger'
module
Gitlab
module
Gitlab
module
Metrics
module
Metrics
module
Samplers
module
Samplers
...
@@ -43,11 +44,14 @@ module Gitlab
...
@@ -43,11 +44,14 @@ module Gitlab
private
private
attr_reader
:running
def
start_working
def
start_working
@running
=
true
@running
=
true
sleep
(
sleep_interval
)
sleep
(
sleep_interval
)
while
running
while
running
safe_sample
safe_sample
sleep
(
sleep_interval
)
end
end
end
end
...
...
lib/gitlab/metrics/samplers/ruby_sampler.rb
View file @
3cc28601
...
@@ -32,7 +32,7 @@ module Gitlab
...
@@ -32,7 +32,7 @@ module Gitlab
def
init_metrics
def
init_metrics
metrics
=
{}
metrics
=
{}
metrics
[
:sampler_duration
]
=
Gitlab
::
Metrics
.
histogram
(
with_prefix
(
:sampler_duration
,
:seconds
),
'Sampler time'
,
source_label
)
metrics
[
:sampler_duration
]
=
Gitlab
::
Metrics
.
histogram
(
with_prefix
(
:sampler_duration
,
:seconds
),
'Sampler time'
,
{}
)
metrics
[
:total_time
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
:time_total
),
'Total GC time'
,
labels
,
:livesum
)
metrics
[
:total_time
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
:time_total
),
'Total GC time'
,
labels
,
:livesum
)
GC
.
stat
.
keys
.
each
do
|
key
|
GC
.
stat
.
keys
.
each
do
|
key
|
metrics
[
key
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
key
),
to_doc_string
(
key
),
labels
,
:livesum
)
metrics
[
key
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
key
),
to_doc_string
(
key
),
labels
,
:livesum
)
...
...
lib/gitlab/metrics/transaction.rb
View file @
3cc28601
...
@@ -43,18 +43,18 @@ module Gitlab
...
@@ -43,18 +43,18 @@ module Gitlab
def
self
.
metric_transaction_duration_milliseconds
def
self
.
metric_transaction_duration_milliseconds
@metrics_transaction_duration_milliseconds
||=
Gitlab
::
Metrics
.
histogram
(
@metrics_transaction_duration_milliseconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_duration_milliseconds
,
:gitlab_transaction_duration_milliseconds
,
'
Method
duration milliseconds'
,
'
Transaction
duration milliseconds'
,
{},
{},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
5
000
]
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
500
,
10
000
]
)
)
end
end
def
self
.
metric_transaction_allocated_memory_bytes
def
self
.
metric_transaction_allocated_memory_
mega
bytes
@metric_transaction_allocated_memory_bytes
||=
Gitlab
::
Metrics
.
histogram
(
@metric_transaction_allocated_memory_
mega
bytes
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_allocated_memory_bytes
,
:gitlab_transaction_allocated_memory_
mega
bytes
,
'
Method duration millisecond
s'
,
'
Transaction allocated memory byte
s'
,
{},
{},
[
1
000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
50000
00
]
[
1
,
2
,
5
,
10
,
20
,
1
00
]
)
)
end
end
...
@@ -69,8 +69,8 @@ module Gitlab
...
@@ -69,8 +69,8 @@ module Gitlab
@memory_after
=
System
.
memory_usage
@memory_after
=
System
.
memory_usage
@finished_at
=
System
.
monotonic_time
@finished_at
=
System
.
monotonic_time
self
.
class
.
metric_transaction_duration_milliseconds
.
observe
({},
duration
)
Transaction
.
metric_transaction_duration_milliseconds
.
observe
({},
duration
)
self
.
class
.
metric_transaction_allocated_memory_
bytes
.
observe
({},
allocated_memory
)
Transaction
.
metric_transaction_allocated_memory_mega
bytes
.
observe
({},
allocated_memory
)
Thread
.
current
[
THREAD_KEY
]
=
nil
Thread
.
current
[
THREAD_KEY
]
=
nil
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