Sha256: 1161c308b6b0e04c534f8ad0ff3102702f614b241905dc2ceac2e048b7bc610c

Contents?: true

Size: 843 Bytes

Versions: 11

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

module ElasticAPM
  # @api private
  module Injectors
    # @api private
    class RedisInjector
      # rubocop:disable Metrics/MethodLength
      def install
        ::Redis::Client.class_eval do
          alias call_without_apm call

          def call(command, &block)
            name = command[0].upcase
            statement =
              format('%s %s', name, command[1..command.length].join(' '))
            context = Span::Context.new(
              statement: statement,
              type: 'redis'
            )

            ElasticAPM.span(name.to_s, 'db.redis', context: context) do
              call_without_apm(command, &block)
            end
          end
        end
      end
      # rubocop:enable Metrics/MethodLength
    end

    register 'Redis', 'redis', RedisInjector.new
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
elastic-apm-0.5.1 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.5.0 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.4.5 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.4.4 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.4.3 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.4.2 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.4.1 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.4.0 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.3.0 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.2.0 lib/elastic_apm/injectors/redis.rb
elastic-apm-0.1.0 lib/elastic_apm/injectors/redis.rb