Class: RorVsWild::Plugin::Redis
- Inherits:
-
Object
- Object
- RorVsWild::Plugin::Redis
- Defined in:
- lib/rorvswild/plugin/redis.rb
Constant Summary collapse
- APPENDABLE_COMMANDS =
[:auth, :select]
Class Method Summary collapse
Class Method Details
.appendable_commands?(commands) ⇒ Boolean
26 27 28 |
# File 'lib/rorvswild/plugin/redis.rb', line 26 def self.appendable_commands?(commands) commands.size == 1 && APPENDABLE_COMMANDS.include?(commands.first.first) end |
.commands_to_string(commands) ⇒ Object
20 21 22 |
# File 'lib/rorvswild/plugin/redis.rb', line 20 def self.commands_to_string(commands) commands.map { |c| c[0] == :auth ? "auth *****".freeze : c.join(" ".freeze) }.join("\n".freeze) end |
.setup ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rorvswild/plugin/redis.rb', line 4 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 |