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

Ruby 3.2.0 gauge error for the RubyVM.stat API changes #2534

Closed
intrip opened this issue Jan 11, 2023 · 7 comments · Fixed by #2600
Closed

Ruby 3.2.0 gauge error for the RubyVM.stat API changes #2534

intrip opened this issue Jan 11, 2023 · 7 comments · Fixed by #2600
Labels
bug Involves a bug community Was opened by a community member
Milestone

Comments

@intrip
Copy link

intrip commented Jan 11, 2023

Current behavior

The gem started logging the following error in our app after we upgraded to Ruby 3.2.0:

E, [2023-01-11T09:02:59.815928 #1] ERROR -- ddtrace: [ddtrace] (/usr/local/bundle/ruby/3.2.0/gems/ddtrace-1.5.0/lib/datadog/core/metrics/client.rb:137:in `rescue in gauge') Failed to send gauge stat. Cause: ArgumentError ArgumentError Source: /usr/local/bundle/ruby/3.2.0/gems/ddtrace-1.5.0/lib/datadog/core/metrics/client.rb:133:in `gauge'

Expected behaviour

The error shouldn't occur.

Steps to reproduce

Use any version of the ddtrace library (even the latest) on Ruby 3.2.0. When a metric flush occurs the above error is logged.

How does ddtrace help you?

The library should handle correctly the new Ruby 3.2.0 RubyVM.stat changes and rely on the new key :constant_cache_invalidations instead of :global_constant_state for Ruby >= 3.2.0. It might also gauge the newly added key :constant_cache_misses when available.

See ruby/ruby#5433, https://github.com/DataDog/dd-trace-rb/blob/v1.5.0/lib/datadog/core/environment/vm_cache.rb#L23-L25, newrelic/newrelic-ruby-agent#1436

Environment

  • ddtrace version: I've tested with 1.5.0 and 1.8.0 but looks like all the versions are affected
  • Configuration block (Datadog.configure ...):
  • Ruby version: 3.2.0
  • Operating system: Ubuntu Focal
  • Relevant library versions:
@intrip intrip added bug Involves a bug community Was opened by a community member labels Jan 11, 2023
@marcotc
Copy link
Member

marcotc commented Jan 12, 2023

Thank you, @intrip.

We are still trying to get our CI to pass in Ruby 3.2: #2497

This issue is covered by tests and I noticed it indeed fails in 3.2.

We'll address this issue when #2497 is merged.

@intrip
Copy link
Author

intrip commented Jan 12, 2023

Thank you @marcotc! Sorry I haven't noticed that 3.2 is not supported yet 😅.

Right now I've come up with this monkey patch to workaround it:

Datadog::Core::Environment::VMCache.class_eval do
  module_function
  # Ruby >= 3.2 uses :constant_cache_invalidations instead of :global_constant_state
  # This is a temporary workaround, the correct solution is to report both :constant_cache_invalidations and :constant_cache_misses in DD
  # See https://github.com/ruby/ruby/pull/5433,
  #     https://github.com/DataDog/dd-trace-rb/blob/v1.5.0/lib/datadog/core/environment/vm_cache.rb#L23-L25
  def global_constant_state
    RubyVM.stat[:constant_cache_invalidations]
  end
end

Unfortunately, I've already shipped a Ruby 3.2 upgrade in one of our apps (with this patch). I haven't noticed any other major breakage so far but I'm afraid there are some subtle unnoticed errors, so right now I'm afraid to push forward a Ruby 3.2 upgrade on our main app, which has a lot of traffic.

Do you have any ETA of when the Ruby 3.2 support will be available?

@sohilsathe
Copy link

+1

thank you for the support!

@unicornzero
Copy link

@intrip Thank you for posting such a comprehensive issue report along with a temporary patch and linked references! This was a huge help to me today. Thank you!

@ivoanjo
Copy link
Member

ivoanjo commented Feb 6, 2023

Thanks @intrip for the workaround and everyone for the patience. We're working on a fix for this and expect it to be included on the next dd-trace-rb release.

ivoanjo added a commit that referenced this issue Feb 7, 2023
ddtrace will now report the new stats, as well as not try to report
stats that are nil, so that in the future as Ruby evolves we won't
break again as we did in #2534.

Fixes #2534
ivoanjo added a commit that referenced this issue Feb 7, 2023
ddtrace will now report the new stats, as well as not try to report
stats that are nil, so that in the future as Ruby evolves we won't
break again as we did in #2534.

Fixes #2534
@ivoanjo ivoanjo added this to the 1.10.0 milestone Feb 7, 2023
@unicornzero
Copy link

@ivoanjo thank you so much for tackling this issue this week! And thank you for the updates. I want to set a reminder to check for an update so I can remove my patch in my code. What's your best guess as to a possible timeline for the 1.10 release?

@ivoanjo
Copy link
Member

ivoanjo commented Feb 14, 2023

We aim to get a new release out every 4-8 weeks, which would put 1.10 towards the end of February/sometime in March.

But, do let us know If this (or any other) issue is blocking or being really annoying for you, that helps us prioritize an earlier release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants