Sha256: dbf295bb0304d17637d92a2dece9d276ba8eba659565f7b68abacd2b436d30bc

Contents?: true

Size: 963 Bytes

Versions: 9

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

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

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

        compatible do
          Gem.loaded_specs['rdkafka'].version >= MINIMUM_VERSION
        end

        install do |_config|
          require_patches
          patch
        end

        present do
          defined?(::Rdkafka)
        end

        private

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

        def patch
          ::Rdkafka::Producer.prepend(Patches::Producer)
          ::Rdkafka::Consumer.prepend(Patches::Consumer)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-rdkafka-0.4.0 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.3.2 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.3.1 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.3.0 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.2.3 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.2.2 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.2.1 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.2.0 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb
opentelemetry-instrumentation-rdkafka-0.1.0 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb