Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-07-18 16:45:00 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-07-18 16:45:00 +0300
commit91903d3a9eb3f72dd0684c983fb200ae14a8eb33 (patch)
tree0224a162251b289df268cfee6d3a899c45085149 /lib
parent133c9330e5e06d703aaf24d21d5beb70b67e5e2d (diff)
parent9dd59df6991b9d82bcbb95bf406194aab8ecf743 (diff)
Merge branch 'sh-fix-redis-performance-bar' into 'master'
Fix inconsistency in Redis performance bar stats Closes #64707 See merge request gitlab-org/gitlab-ce!30866
Diffstat (limited to 'lib')
-rw-r--r--lib/peek/views/redis_detailed.rb (renamed from lib/peek/views/redis.rb)48
1 files changed, 33 insertions, 15 deletions
diff --git a/lib/peek/views/redis.rb b/lib/peek/views/redis_detailed.rb
index 73de8672fa4..12760c9b75e 100644
--- a/lib/peek/views/redis.rb
+++ b/lib/peek/views/redis_detailed.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'redis'
-require 'peek-redis'
module Gitlab
module Peek
@@ -36,11 +35,42 @@ end
module Peek
module Views
- module RedisDetailed
+ class RedisDetailed < View
REDACTED_MARKER = "<redacted>"
+ def key
+ 'redis'
+ end
+
def results
- super.merge(details: details)
+ {
+ 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
+
+ def calls
+ detail_store.count
end
def details
@@ -49,10 +79,6 @@ module Peek
.map(&method(:format_call_details))
end
- def detail_store
- ::Gitlab::SafeRequestStore['redis_call_details'] ||= []
- end
-
def format_call_details(call)
call.merge(cmd: format_command(call[:cmd]),
duration: (call[:duration] * 1000).round(3))
@@ -76,11 +102,3 @@ end
class Redis::Client
prepend Gitlab::Peek::RedisInstrumented
end
-
-module Peek
- module Views
- class Redis < View
- prepend Peek::Views::RedisDetailed
- end
- end
-end