Module: Datadog::Contrib::ActiveSupport::Cache::Instrumentation::WriteMulti

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

Overview

Defines instrumentation for ActiveSupport cache writing of multiple keys

Instance Method Summary collapse

Instance Method Details

#write_multi(hash, options = nil) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/ddtrace/contrib/active_support/cache/instrumentation.rb', line 212

def write_multi(hash, options = nil)
  payload = {
    action: Ext::RESOURCE_CACHE_MSET,
    keys: hash.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