Sha256: c201b58812ca46972cbaeea959e6254e0abf76c102b8a671f1ab87c31f5d7d7c

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

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

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

        present do
          defined?(::Dalli)
        end

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

        private

        def require_dependencies
          require_relative 'utils'
          require_relative 'patches/server'
        end

        def add_patches
          if Gem::Version.new(::Dalli::VERSION) < Gem::Version.new('3.0.0')
            ::Dalli::Server.prepend(Patches::Server)
          else
            ::Dalli::Protocol::Binary.prepend(Patches::Server)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-dalli-0.25.4 lib/opentelemetry/instrumentation/dalli/instrumentation.rb
opentelemetry-instrumentation-dalli-0.25.3 lib/opentelemetry/instrumentation/dalli/instrumentation.rb
opentelemetry-instrumentation-dalli-0.25.1 lib/opentelemetry/instrumentation/dalli/instrumentation.rb
opentelemetry-instrumentation-dalli-0.25.0 lib/opentelemetry/instrumentation/dalli/instrumentation.rb