lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb in opentelemetry-instrumentation-ruby_kafka-0.12.0 vs lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb in opentelemetry-instrumentation-ruby_kafka-0.13.0
- old
+ new
@@ -8,19 +8,29 @@
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)
+ !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'