Skip to content

Commit 2b1ce12

Browse files
authored
feat: rdkafka support to v0.19 including (#1403)
feat: rdkafka support to v0.19 Up to version v0.20.0 it is expected that changes are only in method signatures, so try supporting up to it rel #1325
1 parent 32e8fcb commit 2b1ce12

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

instrumentation/rdkafka/Appraisals

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# SPDX-License-Identifier: Apache-2.0
66

7-
%w[0.12.0 0.13.0 0.14.0].each do |version|
7+
%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|
88
appraise "rdkafka-#{version}" do
99
gem 'rdkafka', "~> #{version}"
1010
end

instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Rdkafka
1111
class Instrumentation < OpenTelemetry::Instrumentation::Base
1212
compatible do
1313
gem_version = Gem::Version.new(::Rdkafka::VERSION)
14-
Gem::Requirement.new('>= 0.10.0', '< 0.15.0').satisfied_by?(gem_version)
14+
Gem::Requirement.new('>= 0.10.0', '< 0.20.0').satisfied_by?(gem_version)
1515
end
1616

1717
install do |_config|

instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ module Rdkafka
1010
module Patches
1111
# The Producer module contains the instrumentation patch the Producer#produce method
1212
module Producer
13-
def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil)
13+
def produce(*args, **kwargs)
14+
topic = kwargs[:topic]
15+
headers = kwargs[:headers] || {}
1416
attributes = {
1517
'messaging.system' => 'kafka',
1618
'messaging.destination' => topic,
1719
'messaging.destination_kind' => 'topic'
1820
}
1921

20-
headers ||= {}
21-
2222
tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do
2323
OpenTelemetry.propagation.inject(headers)
24+
kwargs[:headers] = headers
2425
super
2526
end
2627
end

0 commit comments

Comments
 (0)