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
fdd24d0f
Commit
fdd24d0f
authored
Jun 12, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly measure Redis nested array responses
parent
e65dfa05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
lib/gitlab/instrumentation/redis_interceptor.rb
lib/gitlab/instrumentation/redis_interceptor.rb
+8
-9
spec/lib/gitlab/instrumentation/redis_interceptor_spec.rb
spec/lib/gitlab/instrumentation/redis_interceptor_spec.rb
+3
-0
No files found.
lib/gitlab/instrumentation/redis_interceptor.rb
View file @
fdd24d0f
...
...
@@ -61,15 +61,14 @@ module Gitlab
# 4. "Binary" string (i.e. may contain zero byte)
# 5. Array of binary string
size
=
if
result
.
is_a?
Array
# This count is an approximation that omits the Redis protocol overhead
# of type prefixes, length prefixes and line endings.
result
.
inject
(
0
)
{
|
sum
,
y
|
sum
+
y
.
to_s
.
bytesize
}
else
result
.
to_s
.
bytesize
end
instrumentation_class
.
increment_read_bytes
(
size
)
if
result
.
is_a?
Array
# Redis can return nested arrays, e.g. from XRANGE or GEOPOS, so we use recursion here.
result
.
each
{
|
x
|
measure_read_size
(
x
)
}
else
# This count is an approximation that omits the Redis protocol overhead
# of type prefixes, length prefixes and line endings.
instrumentation_class
.
increment_read_bytes
(
result
.
to_s
.
bytesize
)
end
end
# That's required so it knows which GitLab Redis instance
...
...
spec/lib/gitlab/instrumentation/redis_interceptor_spec.rb
View file @
fdd24d0f
...
...
@@ -24,6 +24,9 @@ describe Gitlab::Instrumentation::RedisInterceptor, :clean_gitlab_redis_shared_s
# Exercise counting of a bulk reply
[[
:set
,
'foo'
,
'bar'
*
100
]]
|
[
:get
,
'foo'
]
|
3
+
3
|
3
*
100
# Nested array response: ['123456-89', ['foo', 'bar']]
[[
:xadd
,
'mystream'
,
'123456-89'
,
'foo'
,
'bar'
]]
|
[
:xrange
,
'mystream'
,
'-'
,
'+'
]
|
6
+
8
+
1
+
1
|
9
+
3
+
3
end
with_them
do
...
...
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