Class: Puff::Instrumentation::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Puff::Instrumentation::LogSubscriber
- Defined in:
- lib/puff/instrumentation/log_subscriber.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_runtime ⇒ Object
14 15 16 17 |
# File 'lib/puff/instrumentation/log_subscriber.rb', line 14 def self.reset_runtime rt, self.runtime = runtime, 0 rt end |
.runtime ⇒ Object
10 11 12 |
# File 'lib/puff/instrumentation/log_subscriber.rb', line 10 def self.runtime Thread.current["redis_runtime"] ||= 0 end |
.runtime=(value) ⇒ Object
6 7 8 |
# File 'lib/puff/instrumentation/log_subscriber.rb', line 6 def self.runtime=(value) Thread.current["redis_runtime"] = value end |
Instance Method Details
#request(event) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puff/instrumentation/log_subscriber.rb', line 19 def request(event) self.class.runtime += event.duration return unless logger.debug? name = "%s (%.2fms)" % ["Redis", event.duration] cmds = event.payload[:commands] output = " #{color(name, RED, true)}" cmds.each do |name, *args| if args.present? output << " #{name.to_s.upcase} #{args.join(" ")}" else output << " #{name.to_s.upcase}" end end debug output end |