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

`ActiveSupport::Cache#read_multi` is not instrumented when using `ActiveSupport::Cache::RedisCacheStore`

Open beauraF opened this issue 1 year ago • 3 comments

Hello 👋

Current behaviour When using Rails.cache.read_multi, using ActiveSupport::Cache::RedisCacheStore, the action is not instrumented. While read, write, fetch, write_multi and fetch_multi are.

This is because ActiveSupport::Cache::RedisCacheStore defines its own read_multi method, and we never go down into ddtrace wrapper method: https://github.com/rails/rails/blob/edbe4672e6b070ebaa5cd60810859e76c283a35a/activesupport/lib/active_support/cache/redis_cache_store.rb#L172

=> [#<Class:#<ActiveSupport::Cache::RedisCacheStore:0x000000013eb1ac30>>,
 ActiveSupport::Cache::Strategy::LocalCache,
 ActiveSupport::Cache::RedisCacheStore,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::Delete,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::WriteMulti,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::Write,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::FetchMulti,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::Fetch,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::ReadMulti,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::Read,
 Datadog::Tracing::Contrib::ActiveSupport::Cache::Instrumentation::InstanceMethods,
 ActiveSupport::Cache::Store,
...
]

Expected behaviour ActiveSupport::Cache::RedisCacheStore#read_multi is instrumented.

Environment

  • datadog version: 1.21.1
  • Relevant library versions:
    • Rails 7.1.3.2

beauraF avatar Apr 22 '24 12:04 beauraF

duplicate of #3549, I believe

naveg avatar Apr 23 '24 21:04 naveg

Clearly linked. But in our case that's the other way around, as we have rails > 5.2 and don't use activesupport-redis, that's what I wanted to put in light. In our case, only ActiveSupport::Cache::Store is patched, and not ActiveSupport::Cache::RedisCacheStore

beauraF avatar Apr 25 '24 07:04 beauraF

ah, yes - you are correct

naveg avatar Apr 26 '24 00:04 naveg

We just released v2.2.0. Give it a try!

TonyCTHsu avatar Jul 11 '24 11:07 TonyCTHsu