module NewRelic::Agent::Instrumentation::Rdkafka::Chain
Public Class Methods
instrument!()
click to toggle source
# File lib/new_relic/agent/instrumentation/rdkafka/chain.rb, line 9 def self.instrument! ::Rdkafka::Producer.class_eval do include NewRelic::Agent::Instrumentation::Rdkafka alias_method(:produce_without_new_relic, :produce) def produce(**kwargs) produce_with_new_relic(kwargs) do |headers| kwargs[:headers] = headers produce_without_new_relic(**kwargs) end end end ::Rdkafka::Consumer.class_eval do include NewRelic::Agent::Instrumentation::Rdkafka alias_method(:each_without_new_relic, :each) def each(**kwargs) each_without_new_relic(**kwargs) do |message| each_with_new_relic(message) do yield(message) end end end end ::Rdkafka::Config.class_eval do include NewRelic::Agent::Instrumentation::RdkafkaConfig alias_method(:producer_without_new_relic, :producer) alias_method(:consumer_without_new_relic, :consumer) if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0') || (Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')) def producer(**kwargs) producer_without_new_relic(**kwargs).tap do |producer| set_nr_config(producer) end end def consumer(**kwargs) consumer_without_new_relic(**kwargs).tap do |consumer| set_nr_config(consumer) end end else def producer producer_without_new_relic.tap do |producer| set_nr_config(producer) end end def consumer consumer_without_new_relic.tap do |consumer| set_nr_config(consumer) end end end end end
Public Instance Methods
consumer(**kwargs)
click to toggle source
# File lib/new_relic/agent/instrumentation/rdkafka/chain.rb, line 51 def consumer(**kwargs) consumer_without_new_relic(**kwargs).tap do |consumer| set_nr_config(consumer) end end
each(**kwargs) { |message| ... }
click to toggle source
# File lib/new_relic/agent/instrumentation/rdkafka/chain.rb, line 28 def each(**kwargs) each_without_new_relic(**kwargs) do |message| each_with_new_relic(message) do yield(message) end end end
produce(**kwargs)
click to toggle source
# File lib/new_relic/agent/instrumentation/rdkafka/chain.rb, line 15 def produce(**kwargs) produce_with_new_relic(kwargs) do |headers| kwargs[:headers] = headers produce_without_new_relic(**kwargs) end end
producer(**kwargs)
click to toggle source
# File lib/new_relic/agent/instrumentation/rdkafka/chain.rb, line 45 def producer(**kwargs) producer_without_new_relic(**kwargs).tap do |producer| set_nr_config(producer) end end