Class: Skylight::Core::Probes::Redis::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/redis.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

PIPELINED_OPTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Unfortunately, because of the nature of pipelining, there's no way for us to give a time breakdown on the individual items.

{
  category: "db.redis.pipelined".freeze,
  title:    "PIPELINE".freeze
}.freeze
MULTI_OPTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  category: "db.redis.multi".freeze,
  title:    "MULTI".freeze
}.freeze

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/skylight/core/probes/redis.rb', line 5

def install
  version = defined?(::Redis::VERSION) ? Gem::Version.new(::Redis::VERSION) : nil

  if !version || version < Gem::Version.new("3.0.0")
    # Using $stderr here isn't great, but we don't have a logger accessible
    $stderr.puts "[SKYLIGHT::CORE] [#{Skylight::Core::VERSION}] The installed version of Redis doesn't " \
                  "support Middlewares. At least version 3.0.0 is required."
    return
  end

  ::Redis::Client.class_eval do
    alias_method :call_without_sk, :call

    def call(command, &block)
      command_name = command[0]

      return call_without_sk(command, &block) if command_name == :auth

      opts = {
        category: "db.redis.command",
        title:    command_name.upcase.to_s
      }

      Skylight::Core::Fanout.instrument(opts) do
        call_without_sk(command, &block)
      end
    end
  end
end