2019-06-28 14:34:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Peek
|
|
|
|
module Views
|
2019-07-24 10:42:45 -04:00
|
|
|
class RedisDetailed < DetailedView
|
2019-07-09 10:07:41 -04:00
|
|
|
REDACTED_MARKER = "<redacted>"
|
|
|
|
|
2019-07-17 15:33:49 -04:00
|
|
|
def key
|
|
|
|
'redis'
|
|
|
|
end
|
|
|
|
|
2020-06-04 08:08:21 -04:00
|
|
|
def detail_store
|
|
|
|
::Gitlab::Instrumentation::Redis.detail_store
|
|
|
|
end
|
|
|
|
|
2019-07-17 15:33:49 -04:00
|
|
|
private
|
|
|
|
|
2019-06-28 14:34:08 -04:00
|
|
|
def format_call_details(call)
|
2022-09-05 23:12:08 -04:00
|
|
|
cmd = call[:commands].map do |command|
|
|
|
|
format_command(command)
|
|
|
|
end.join(', ')
|
|
|
|
|
|
|
|
super.merge(cmd: cmd,
|
2020-06-16 08:09:00 -04:00
|
|
|
instance: call[:storage])
|
2019-06-28 14:34:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def format_command(cmd)
|
2019-07-09 10:07:41 -04:00
|
|
|
if cmd.length >= 2 && cmd.first =~ /^auth$/i
|
|
|
|
cmd[-1] = REDACTED_MARKER
|
2019-06-28 14:34:08 -04:00
|
|
|
# Scrub out the value of the SET calls to avoid binary
|
|
|
|
# data or large data from spilling into the view
|
2019-07-09 10:07:41 -04:00
|
|
|
elsif cmd.length >= 3 && cmd.first =~ /set/i
|
|
|
|
cmd[2..-1] = REDACTED_MARKER
|
2019-06-28 14:34:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
cmd.join(' ')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|