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

ActiveSupport::Cache integration does not support multiple cache backends #3549

Closed
naveg opened this issue Mar 21, 2024 · 1 comment · Fixed by #3772
Closed

ActiveSupport::Cache integration does not support multiple cache backends #3549

naveg opened this issue Mar 21, 2024 · 1 comment · Fixed by #3772
Labels
bug Involves a bug community Was opened by a community member

Comments

@naveg
Copy link

naveg commented Mar 21, 2024

Current behaviour
If redis-activesupport is present, then only ActiveSupport::Cache::RedisStore is patched (for methods that it has), and ActiveSupport::Cache::Store is not patched.

def patch_redis?(meth)
!Gem.loaded_specs['redis-activesupport'].nil? \
&& defined?(::ActiveSupport::Cache::RedisStore) \
&& ::ActiveSupport::Cache::RedisStore.instance_methods(false).include?(meth)
end
def cache_store_class(meth)
if patch_redis?(meth)
::ActiveSupport::Cache::RedisStore
else
super
end
end
end

Expected behaviour
ActiveSupport::Cache::Store is always patched, because it may be used with cache backends other than redis.

Steps to reproduce

  • Create an application with with redis-activesupport present
  • Create a cache using a non-redis backend (eg ActiveSupport::Cache::MemCacheStore)
  • Note that cache writes are not instrumented (because we didn't patch the :write method of ActiveSupport::Cache::Store)

One solution could be to patch multiple classes - ie if redis is present and defines the method, patch both classes, rather than one or the other.

Environment

  • ddtrace version: 1.12
  • Configuration block (Datadog.configure ...):
  • Ruby version: 3.0.6
  • Operating system: Linux
  • Relevant library versions:
@TonyCTHsu
Copy link
Contributor

👋 @naveg We just released v2.2.0. Give it a try!

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.

2 participants