Module: Datadog::Contrib::ActiveSupport::Cache::Instrumentation::FetchMulti

Defined in:
lib/ddtrace/contrib/active_support/cache/instrumentation.rb

Overview

Defines instrumentation for ActiveSupport cache fetching of multiple keys

Instance Method Summary collapse

Instance Method Details

#fetch_multi(*args, &block) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/ddtrace/contrib/active_support/cache/instrumentation.rb', line 164

def fetch_multi(*args, &block)
  # extract options hash
  keys = args[-1].instance_of?(Hash) ? args[0..-2] : args
  payload = {
    action: Ext::RESOURCE_CACHE_MGET,
    keys: keys,
    tracing_context: {}
  }

  begin
    # process and catch cache exceptions
    Instrumentation.start_trace_cache(payload)
    super
  rescue Exception => e
    payload[:exception] = [e.class.name, e.message]
    payload[:exception_object] = e
    raise e
  end
ensure
  Instrumentation.finish_trace_cache_multi(payload)
end