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:
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