Skip to content

Commit

Permalink
fixes #630 potential performance hit logging cache key
Browse files Browse the repository at this point in the history
* using ActiveSupport::Cache.expand_cache_key which is also
  used by Rails to expand the cache key without enumerating
  relations
  • Loading branch information
Yoav committed Nov 22, 2018
1 parent 2828552 commit bea2079
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ddtrace/contrib/rails/active_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bea2079

Please sign in to comment.