Sha256: a40ac1765600a959d2179a2595e75cf8f81a6f037d6106ea51d7a987c2ff1b30

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

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

      PIPELINED_OPTS = { category: "db.redis.pipelined".freeze, title: "PIPELINE".freeze, internal: true }.freeze

      MULTI_OPTS = { category: "db.redis.multi".freeze, title: "MULTI".freeze, internal: true }.freeze

      module ClientInstrumentation
        def call(command, *)
          command_name = command[0]

          return super if command_name == :auth

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

          Skylight.instrument(opts) { super }
        end
      end

      module Instrumentation
        def pipelined(*)
          Skylight.instrument(PIPELINED_OPTS) { super }
        end

        def multi(*)
          Skylight.instrument(MULTI_OPTS) { super }
        end
      end

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

          if !version || version < Gem::Version.new("3.0.0")
            Skylight.error "The installed version of Redis doesn't support Middlewares. " \
                             "At least version 3.0.0 is required."
            return
          end

          ::Redis::Client.prepend(ClientInstrumentation)
          ::Redis.prepend(Instrumentation)
        end
      end
    end

    register(:redis, "Redis", "redis", Redis::Probe.new)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
skylight-5.3.3 lib/skylight/probes/redis.rb
skylight-5.3.2 lib/skylight/probes/redis.rb
skylight-5.3.1 lib/skylight/probes/redis.rb
skylight-5.3.0 lib/skylight/probes/redis.rb
skylight-5.2.0 lib/skylight/probes/redis.rb
skylight-5.2.0.beta2 lib/skylight/probes/redis.rb
skylight-5.2.0.beta lib/skylight/probes/redis.rb
skylight-5.1.1 lib/skylight/probes/redis.rb
skylight-5.1.0.beta3 lib/skylight/probes/redis.rb
skylight-5.1.0.beta2 lib/skylight/probes/redis.rb