Module: Datadog::Contrib::ActiveSupport::Cache::Instrumentation::Write

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

Overview

Defines instrumentation for ActiveSupport cache writing

Instance Method Summary collapse

Instance Method Details

#write(*args, &block) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/ddtrace/contrib/active_support/cache/instrumentation.rb', line 189

def write(*args, &block)
  payload = {
    action: Ext::RESOURCE_CACHE_SET,
    key: args[0],
    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(payload)
end