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

redis_detailed.rb « views « peek « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 76c283bf802d847d54d7059bdf274650b1ba02f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

module Peek
  module Views
    class RedisDetailed < DetailedView
      REDACTED_MARKER = "<redacted>"

      def key
        'redis'
      end

      def detail_store
        ::Gitlab::Instrumentation::Redis.detail_store
      end

      private

      def format_call_details(call)
        cmd = call[:commands].map do |command|
          format_command(command)
        end.join(', ')

        super.merge(cmd: cmd,
                    instance: call[:storage])
      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