Sha256: 7782205d33a1e91d836d662407b87fb45df88a0cde416400f98c20eab9beca37

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

module NewRelic::Agent::Instrumentation
  module RubyKafkaProducer
    module Prepend
      include NewRelic::Agent::Instrumentation::RubyKafka

      def produce(value, **kwargs)
        produce_with_new_relic(value, **kwargs) do |headers|
          kwargs[:headers] = headers
          super
        end
      end
    end
  end

  module RubyKafkaConsumer
    module Prepend
      include NewRelic::Agent::Instrumentation::RubyKafka

      if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
        def each_message(**args)
          super do |message|
            each_message_with_new_relic(message) do
              yield(message)
            end
          end
        end
      else
        def each_message(*args)
          super do |message|
            each_message_with_new_relic(message) do
              yield(message)
            end
          end
        end
      end
    end
  end

  module RubyKafkaClient
    module Prepend
      include NewRelic::Agent::Instrumentation::RubyKafkaConfig

      def producer(**kwargs)
        super.tap do |producer|
          set_nr_config(producer)
        end
      end

      def consumer(**kwargs)
        super.tap do |consumer|
          set_nr_config(consumer)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb