Skip to content

Commit

Permalink
fix: strict rdkafka support to v0.14 (#1326)
Browse files Browse the repository at this point in the history
* fix: strict rdkafka support to v0.14

* squash: fix argument error

* squash: OMG

* squash: skip incompatible versions

* squash: use compatible? predicate
  • Loading branch information
arielvalentin authored Jan 7, 2025
1 parent 0cfc9d0 commit 48b3206
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
10 changes: 4 additions & 6 deletions instrumentation/rdkafka/Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#
# SPDX-License-Identifier: Apache-2.0

appraise 'rdkafka-0.12.x' do
gem 'rdkafka', '~> 0.12.0'
end

appraise 'rdkafka-0.13.x' do
gem 'rdkafka', '~> 0.13.0'
%w[0.12.0 0.13.0 0.14.0].each do |version|
appraise "rdkafka-#{version}" do
gem 'rdkafka', "~> #{version}"
end
end

appraise 'rdkafka-latest' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ module Instrumentation
module Rdkafka
# The Instrumentation class contains logic to detect and install the Rdkafka instrumentation
class Instrumentation < OpenTelemetry::Instrumentation::Base
MINIMUM_VERSION = Gem::Version.new('0.10.0')

compatible do
Gem::Version.new(::Rdkafka::VERSION) >= MINIMUM_VERSION
gem_version = Gem::Version.new(::Rdkafka::VERSION)
Gem::Requirement.new('>= 0.10.0', '< 0.15.0').satisfied_by?(gem_version)
end

install do |_config|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

describe '#install' do
it 'accepts argument' do
skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible?
_(instrumentation.install({})).must_equal(true)
instrumentation.instance_variable_set(:@installed, false)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

describe '#each' do
it 'traces each call' do
skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible?

rand_hash = SecureRandom.hex(10)
topic_name = "consumer-patch-trace-#{rand_hash}"
config = { 'bootstrap.servers': "#{host}:#{port}" }
Expand Down Expand Up @@ -112,6 +114,8 @@
end

it 'encodes messages keys depending on input format' do
skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible?

rand_hash = SecureRandom.hex(10)
topic_name = "consumer-patch-trace-#{rand_hash}"
config = { 'bootstrap.servers': "#{host}:#{port}" }
Expand Down Expand Up @@ -164,6 +168,8 @@

describe '#each_batch' do
it 'traces each_batch call' do
skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible?

rand_hash = SecureRandom.hex(10)
topic_name = "consumer-patch-batch-trace-#{rand_hash}"
config = { 'bootstrap.servers': "#{host}:#{port}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

describe 'tracing' do
it 'traces sync produce calls' do
skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible?
topic_name = 'producer-patch-trace'
config = { 'bootstrap.servers': "#{host}:#{port}" }

Expand Down

0 comments on commit 48b3206

Please sign in to comment.