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
e2710429
Commit
e2710429
authored
Jul 24, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ace9185c
6a5d2df3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
72 deletions
+65
-72
lib/peek/views/detailed_view.rb
lib/peek/views/detailed_view.rb
+49
-0
lib/peek/views/gitaly.rb
lib/peek/views/gitaly.rb
+4
-23
lib/peek/views/redis_detailed.rb
lib/peek/views/redis_detailed.rb
+2
-21
lib/peek/views/rugged.rb
lib/peek/views/rugged.rb
+10
-25
spec/lib/peek/views/rugged_spec.rb
spec/lib/peek/views/rugged_spec.rb
+0
-3
No files found.
lib/peek/views/detailed_view.rb
0 → 100644
View file @
e2710429
# frozen_string_literal: true
module
Peek
module
Views
class
DetailedView
<
View
def
results
{
duration:
formatted_duration
,
calls:
calls
,
details:
details
}
end
private
def
duration
raise
NotImplementedError
end
def
calls
raise
NotImplementedError
end
def
call_details
raise
NotImplementedError
end
def
format_call_details
(
call
)
raise
NotImplementedError
end
def
details
call_details
.
sort
{
|
a
,
b
|
b
[
:duration
]
<=>
a
[
:duration
]
}
.
map
(
&
method
(
:format_call_details
))
end
def
formatted_duration
ms
=
duration
*
1000
if
ms
>=
1000
"%.2fms"
%
ms
else
"%.0fms"
%
ms
end
end
end
end
end
lib/peek/views/gitaly.rb
View file @
e2710429
...
...
@@ -2,7 +2,9 @@
module
Peek
module
Views
class
Gitaly
<
View
class
Gitaly
<
DetailedView
private
def
duration
::
Gitlab
::
GitalyClient
.
query_time
end
...
...
@@ -11,20 +13,8 @@ module Peek
::
Gitlab
::
GitalyClient
.
get_request_count
end
def
results
{
duration:
formatted_duration
,
calls:
calls
,
details:
details
}
end
private
def
details
def
call_details
::
Gitlab
::
GitalyClient
.
list_call_details
.
sort
{
|
a
,
b
|
b
[
:duration
]
<=>
a
[
:duration
]
}
.
map
(
&
method
(
:format_call_details
))
end
def
format_call_details
(
call
)
...
...
@@ -34,15 +24,6 @@ module Peek
request:
pretty_request
||
{})
end
def
formatted_duration
ms
=
duration
*
1000
if
ms
>=
1000
"%.2fms"
%
ms
else
"%.0fms"
%
ms
end
end
def
setup_subscribers
subscribe
'start_processing.action_controller'
do
::
Gitlab
::
GitalyClient
.
query_time
=
0
...
...
lib/peek/views/redis_detailed.rb
View file @
e2710429
...
...
@@ -35,36 +35,19 @@ end
module
Peek
module
Views
class
RedisDetailed
<
View
class
RedisDetailed
<
Detailed
View
REDACTED_MARKER
=
"<redacted>"
def
key
'redis'
end
def
results
{
calls:
calls
,
duration:
formatted_duration
,
details:
details
}
end
def
detail_store
::
Gitlab
::
SafeRequestStore
[
'redis_call_details'
]
||=
[]
end
private
def
formatted_duration
ms
=
duration
*
1000
if
ms
>=
1000
"%.2fms"
%
ms
else
"%.0fms"
%
ms
end
end
def
duration
detail_store
.
map
{
|
entry
|
entry
[
:duration
]
}.
sum
# rubocop:disable CodeReuse/ActiveRecord
end
...
...
@@ -73,10 +56,8 @@ module Peek
detail_store
.
count
end
def
details
def
call_
details
detail_store
.
sort
{
|
a
,
b
|
b
[
:duration
]
<=>
a
[
:duration
]
}
.
map
(
&
method
(
:format_call_details
))
end
def
format_call_details
(
call
)
...
...
lib/peek/views/rugged.rb
View file @
e2710429
...
...
@@ -2,7 +2,15 @@
module
Peek
module
Views
class
Rugged
<
View
class
Rugged
<
DetailedView
def
results
return
{}
unless
calls
>
0
super
end
private
def
duration
::
Gitlab
::
RuggedInstrumentation
.
query_time
end
...
...
@@ -11,22 +19,8 @@ module Peek
::
Gitlab
::
RuggedInstrumentation
.
query_count
end
def
results
return
{}
unless
calls
>
0
{
duration:
formatted_duration
,
calls:
calls
,
details:
details
}
end
private
def
details
def
call_details
::
Gitlab
::
RuggedInstrumentation
.
list_call_details
.
sort
{
|
a
,
b
|
b
[
:duration
]
<=>
a
[
:duration
]
}
.
map
(
&
method
(
:format_call_details
))
end
def
format_call_details
(
call
)
...
...
@@ -44,15 +38,6 @@ module Peek
end
end
end
def
formatted_duration
ms
=
duration
*
1000
if
ms
>=
1000
"%.2fms"
%
ms
else
"%.0fms"
%
ms
end
end
end
end
end
spec/lib/peek/views/rugged_spec.rb
View file @
e2710429
...
...
@@ -27,9 +27,6 @@ describe Peek::Views::Rugged, :request_store do
args:
[
project
.
repository
.
raw
,
'refs/heads/master'
],
duration:
0.456
)
expect
(
subject
.
duration
).
to
be_within
(
0.00001
).
of
(
1.234
)
expect
(
subject
.
calls
).
to
eq
(
2
)
results
=
subject
.
results
expect
(
results
[
:calls
]).
to
eq
(
2
)
expect
(
results
[
:duration
]).
to
eq
(
'1234.00ms'
)
...
...
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