From bea2079b551cc2be9ea8f2ab3f11689f2129e0b3 Mon Sep 17 00:00:00 2001 From: Yoav Date: Thu, 22 Nov 2018 08:19:12 +0000 Subject: [PATCH] fixes #630 potential performance hit logging cache key * using ActiveSupport::Cache.expand_cache_key which is also used by Rails to expand the cache key without enumerating relations --- lib/ddtrace/contrib/rails/active_support.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ddtrace/contrib/rails/active_support.rb b/lib/ddtrace/contrib/rails/active_support.rb index 6167dfbf7c1..af7c1578a20 100644 --- a/lib/ddtrace/contrib/rails/active_support.rb +++ b/lib/ddtrace/contrib/rails/active_support.rb @@ -50,7 +50,8 @@ def self.finish_trace_cache(payload) # discard parameters from the cache_store configuration store, = *Array.wrap(::Rails.configuration.cache_store).flatten span.set_tag(Ext::TAG_CACHE_BACKEND, store) - cache_key = Datadog::Utils.truncate(payload.fetch(:key), Ext::QUANTIZE_CACHE_MAX_KEY_SIZE) + normalized_key = ActiveSupport::Cache.expand_cache_key(payload.fetch(:key)) + cache_key = Datadog::Utils.truncate(normalized_key, Ext::QUANTIZE_CACHE_MAX_KEY_SIZE) span.set_tag(Ext::TAG_CACHE_KEY, cache_key) span.set_error(payload[:exception]) if payload[:exception] ensure