Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: suppress deprecation warning in Rdkafka Instrumentation #884

Merged

Conversation

yoheyk
Copy link
Contributor

@yoheyk yoheyk commented Feb 21, 2024

Background

Observing the following warning with rdkafka 0.13.0 and above:

https://github.com/open-telemetry/opentelemetry-ruby-contrib/actions/runs/7980847049/job/21791353080#step:4:224

rdkafka deprecation warning: header access with Symbol key :traceparent treated as a String. Please change your code to use String keys to avoid this warning. Symbol keys will break in version 1.

This warning is coming from here:
https://github.com/karafka/rdkafka-ruby/blob/v0.14.0/lib/rdkafka/consumer/headers.rb#L10-L11

Changes summary

Use Context::Propagation.text_map_getter with rdkafka 0.13.0 and above.

if we can drop support for rdkafka 0.12.0, it's going to be much simpler

Copy link
Collaborator

@arielvalentin arielvalentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your continued support here!

I have a question about potentially reducing the number of checks that I left in line.

@@ -74,6 +74,14 @@ def extract_message_key(key)
rescue Encoding::UndefinedConversionError
nil
end

def getter
if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.13.0')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to check/set this only once when the gem is activated as opposed to each time a message is processed?

Copy link
Contributor Author

@yoheyk yoheyk Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could memoize like 661cd67 or do you think it's better to use a constant like this?

          GETTER = if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.13.0')
              Context::Propagation.text_map_getter
            else
              OpenTelemetry::Common::Propagation.symbol_key_getter
            end
          private_constant :GETTER

(btw we still need to support rdkafka 0.12.0, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, 0.12.0 is released on June 17, 2022, and the latest version of rdkafka is 0.15.1 as of now

https://rubygems.org/gems/rdkafka/versions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general rule is for any gems we try to support any non-EoL versions, however since all of these are pre 1.0 we have more flexibility and may choose to drop support for earlier versions at any time.

I also usually check with the original contributor of this instrumentation to provide a review and get their feedback on whether or not it makes sense to continue to support older versions.

We will generally provide guidance on pinning to an older version of the instrumentation in the README.

Copy link
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale Marks an issue/PR stale label Mar 25, 2024
@@ -74,6 +74,14 @@ def extract_message_key(key)
rescue Encoding::UndefinedConversionError
nil
end

def getter
@getter ||= if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.13.0')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very sorry for the delayed review.

Is this something that can be checked at installation time as opposed to when the worker processes the first message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about this? 21e4a43

@arielvalentin arielvalentin added keep Ensures stale-bot keeps this issue/PR open and removed stale Marks an issue/PR stale labels Mar 26, 2024
@arielvalentin arielvalentin merged commit 8cbc6b6 into open-telemetry:main Apr 5, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Ensures stale-bot keeps this issue/PR open
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants