Sha256: e45dafcfd35f41456f964ec116311eb577f9b91d02086d6ca2a54862abe0888c

Contents?: true

Size: 1.04 KB

Versions: 38

Compression:

Stored size: 1.04 KB

Contents

module RorVsWild
  module Plugin
    class Redis
      def self.setup
        return if !defined?(::Redis)
        return if ::Redis::Client.method_defined?(:process_without_rorvswild)
        ::Redis::Client.class_eval do
          alias_method :process_without_rorvswild, :process

          def process(commands, &block)
            string = RorVsWild::Plugin::Redis.commands_to_string(commands)
            appendable = RorVsWild::Plugin::Redis.appendable_commands?(commands)
            RorVsWild.agent.measure_section(string, appendable_command: appendable, kind: "redis".freeze) do
              process_without_rorvswild(commands, &block)
            end
          end
        end
      end

      def self.commands_to_string(commands)
        commands.map { |c| c[0] == :auth ? "auth *****".freeze : c.join(" ".freeze) }.join("\n".freeze)
      end

      APPENDABLE_COMMANDS = [:auth, :select]

      def self.appendable_commands?(commands)
        commands.size == 1 && APPENDABLE_COMMANDS.include?(commands.first.first)
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
rorvswild-1.5.13 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.12 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.11 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.10 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.9 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.8 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.7 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.6 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.5 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.4 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.3 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.2 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.1 lib/rorvswild/plugin/redis.rb
rorvswild-1.5.0 lib/rorvswild/plugin/redis.rb
rorvswild-1.4.7 lib/rorvswild/plugin/redis.rb
rorvswild-1.4.6 lib/rorvswild/plugin/redis.rb
rorvswild-1.4.5 lib/rorvswild/plugin/redis.rb
rorvswild-1.4.4 lib/rorvswild/plugin/redis.rb
rorvswild-1.4.3 lib/rorvswild/plugin/redis.rb
rorvswild-1.4.2 lib/rorvswild/plugin/redis.rb