Sha256: 1f2ed9164ab21bc5a1f3a183e77df3b14880131eb1447761072f173dc3489693

Contents?: true

Size: 1.28 KB

Versions: 9

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module Redis
      # The Instrumentation class contains logic to detect and install the Redis
      # instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        install do |_config|
          require_dependencies
          patch_client
        end

        present do
          defined?(::Redis) || defined?(::RedisClient)
        end

        option :peer_service,                 default: nil,   validate: :string
        option :trace_root_spans,             default: true,  validate: :boolean
        option :db_statement,                 default: :obfuscate, validate: %I[omit include obfuscate]

        private

        def require_dependencies
          require_relative 'patches/redis_v4_client' if defined?(::Redis) && ::Redis::VERSION < '5'
          require_relative 'middlewares/redis_client' if defined?(::RedisClient)
        end

        def patch_client
          ::RedisClient.register(Middlewares::RedisClientInstrumentation) if defined?(::RedisClient)
          ::Redis::Client.prepend(Patches::RedisV4Client) if defined?(::Redis) && ::Redis::VERSION < '5'
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-redis-0.25.7 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.25.6 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.25.4 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.25.3 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.25.2 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.25.1 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.25.0 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.24.1 lib/opentelemetry/instrumentation/redis/instrumentation.rb
opentelemetry-instrumentation-redis-0.24.0 lib/opentelemetry/instrumentation/redis/instrumentation.rb