Module: Datadog::Contrib::ActiveSupport::Cache::Instrumentation::Read

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

Overview

Defines instrumentation for ActiveSupport cache reading

Instance Method Summary collapse

Instance Method Details

#read(*args, &block) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ddtrace/contrib/active_support/cache/instrumentation.rb', line 95

def read(*args, &block)
  payload = {
    action: Ext::RESOURCE_CACHE_GET,
    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