Sha256: 693f10b403b1ba00f02fcdf3364e69c53b8802dfb383b4333c320b298567d696

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module RubyKafka
      # The Instrumentation class contains logic to detect and install the
      # KafkaRuby instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        MINIMUM_VERSION = Gem::Version.new('0.7.0')

        install do |_config|
          require_patches
          patch
        end

        present do
          !defined?(::Kafka).nil?
        end

        compatible do
          gem_version >= MINIMUM_VERSION
        end

        private

        def gem_version
          Gem.loaded_specs['ruby-kafka'].version
        end

        def require_patches
          require_relative 'patches/producer'
          require_relative 'patches/consumer'
          require_relative 'patches/client'
        end

        def patch
          ::Kafka::Producer.prepend(Patches::Producer)
          ::Kafka::Consumer.prepend(Patches::Consumer)
          ::Kafka::Client.prepend(Patches::Client)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-ruby_kafka-0.18.2 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.18.1 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.18.0 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.17.0 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.16.0 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.15.0 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.14.0 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb
opentelemetry-instrumentation-ruby_kafka-0.13.0 lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb