Sha256: 57a12510e0532b3b524282359de37e2cb2d770f60c46a3cf4c482d40ac59e020

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 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
        compatible do
          gem_version = Gem::Version.new(::Rdkafka::VERSION)
          Gem::Requirement.new('>= 0.10.0', '< 0.15.0').satisfied_by?(gem_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

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-rdkafka-0.4.9 lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb