debian-mirror-gitlab/lib/peek/views/redis_detailed.rb

41 lines
901 B
Ruby
Raw Normal View History

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