Skip to content

Commit

Permalink
Merge pull request #2915 from patrickarnett/patrickarnett/ruby-kafka-sig
Browse files Browse the repository at this point in the history
Use double splat for Ruby >= 3.0
  • Loading branch information
tannalynn authored Oct 21, 2024
2 parents 3e8c24b + 6a247b6 commit 677f136
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Version <dev> updates View Componment instrumentation to use a default metric na

In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906)

- **Bufix: Instrumentation errors when using the ruby-kafka gem**

Kafka::Consumer#each_message takes keyword arguments, while the prepended method is defined with a single splat positional argument. In Ruby >= 3.0, this signature mismatch raises an ArgumentError. [PR#2915](https://github.com/newrelic/newrelic-ruby-agent/pull/2915)

## v9.14.0

Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka gems, introduces a configuration-based, automatic way to add custom instrumentation method tracers, correctly captures MIME type for ActionDispatch 7.0+ requests, properly handles Boolean coercion for `newrelic.yml` configuration, fixes a JRuby bug in the configuration manager, fixes a bug related to `Bundler.rubygems.installed_specs`, and fixes a bug to make the agent compatible with ViewComponent v3.15.0+.
Expand Down
18 changes: 14 additions & 4 deletions lib/new_relic/agent/instrumentation/ruby_kafka/prepend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ module RubyKafkaConsumer
module Prepend
include NewRelic::Agent::Instrumentation::RubyKafka

def each_message(*args)
super do |message|
each_message_with_new_relic(message) do
yield(message)
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
Expand Down

0 comments on commit 677f136

Please sign in to comment.