dd-trace-rb
dd-trace-rb copied to clipboard
`ActiveSupport::Cache` integration does not support multiple cache backends
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.
https://github.com/DataDog/dd-trace-rb/blob/210ed96858ff889a6d69339ba6fb112d7c68b621/lib/datadog/tracing/contrib/active_support/cache/redis.rb#L25-L38
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-activesupportpresent - 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
:writemethod ofActiveSupport::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: