dd-trace-rb icon indicating copy to clipboard operation
dd-trace-rb copied to clipboard

`ActiveSupport::Cache` integration does not support multiple cache backends

Open naveg opened this issue 11 months ago • 0 comments

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-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:

naveg avatar Mar 21 '24 18:03 naveg