Sha256: 51f7f27ef9917f3a03828a7c95d007780ca1eb86819643b84da7d613f990319c

Contents?: true

Size: 749 Bytes

Versions: 2

Compression:

Stored size: 749 Bytes

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)
            RorVsWild.client.measure_query("redis".freeze, string) do
              process_without_rorvswild(commands, &block)
            end
          end
        end
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rorvswild-0.6.1 lib/rorvswild/plugin/redis.rb
rorvswild-0.6.0 lib/rorvswild/plugin/redis.rb