Skip to content

Commit

Permalink
feat: rdkafka support to v0.19
Browse files Browse the repository at this point in the history
Up to version v0.20.0 it is expected that changes are only in
method signatures, so try supporting up to it

rel #1325
  • Loading branch information
smoke committed Feb 8, 2025
1 parent 32e8fcb commit e8e0e25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion instrumentation/rdkafka/Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

%w[0.12.0 0.13.0 0.14.0].each do |version|
%w[0.12.0 0.13.0 0.14.0 0.15.0 0.16.0 0.17.0 0.18.0 0.19.0].each do |version|
appraise "rdkafka-#{version}" do
gem 'rdkafka', "~> #{version}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Rdkafka
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)
Gem::Requirement.new('>= 0.10.0', '< 0.20.0').satisfied_by?(gem_version)
end

install do |_config|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ module Rdkafka
module Patches
# The Producer module contains the instrumentation patch the Producer#produce method
module Producer
def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil)
def produce(*args, **kwargs)
topic = kwargs[:topic]
headers = kwargs[:headers] || {}
attributes = {
'messaging.system' => 'kafka',
'messaging.destination' => topic,
'messaging.destination_kind' => 'topic'
}

headers ||= {}

tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do
OpenTelemetry.propagation.inject(headers)
kwargs[:headers] = headers
super
end
end
Expand Down

0 comments on commit e8e0e25

Please sign in to comment.