Class: ScoutApm::Instruments::Redis5
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::Redis5
- Defined in:
- lib/scout_apm/instruments/redis5.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(context) ⇒ Redis5
constructor
A new instance of Redis5.
- #install(prepend:) ⇒ Object
- #installed? ⇒ Boolean
- #logger ⇒ Object
Constructor Details
#initialize(context) ⇒ Redis5
Returns a new instance of Redis5.
6 7 8 9 |
# File 'lib/scout_apm/instruments/redis5.rb', line 6 def initialize(context) @context = context @installed = false end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/scout_apm/instruments/redis5.rb', line 4 def context @context end |
Instance Method Details
#install(prepend:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scout_apm/instruments/redis5.rb', line 19 def install(prepend:) if defined?(::Redis) && defined?(::Redis::Client) && ::Redis::Client.instance_methods(false).include?(:call_v) @installed = true logger.info "Instrumenting Redis5. Prepend: #{prepend}" if prepend ::Redis::Client.send(:include, ScoutApm::Tracer) ::Redis::Client.send(:prepend, Redis5ClientInstrumentationPrepend) else ::Redis::Client.class_eval do include ScoutApm::Tracer def call_with_scout_instruments(args, &block) command = args.first rescue "Unknown" self.class.instrument("Redis", command) do call_without_scout_instruments(args, &block) end end alias_method :call_without_scout_instruments, :call_v alias_method :call_v, :call_with_scout_instruments end end end end |
#installed? ⇒ Boolean
15 16 17 |
# File 'lib/scout_apm/instruments/redis5.rb', line 15 def installed? @installed end |
#logger ⇒ Object
11 12 13 |
# File 'lib/scout_apm/instruments/redis5.rb', line 11 def logger context.logger end |