Module: DynamoDB::Chain

Defined in:
lib/new_relic/agent/instrumentation/dynamodb/chain.rb

Class Method Summary collapse

Class Method Details

.instrument!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/new_relic/agent/instrumentation/dynamodb/chain.rb', line 7

def self.instrument!
  ::Aws::DynamoDB::Client.class_eval do
    include NewRelic::Agent::Instrumentation::DynamoDB

    NewRelic::Agent::Instrumentation::DynamoDB::INSTRUMENTED_METHODS.each do |method_name|
      alias_method("#{method_name}_without_new_relic".to_sym, method_name.to_sym)

      define_method(method_name) do |*args|
        instrument_method_with_new_relic(method_name, *args) { send("#{method_name}_without_new_relic".to_sym, *args) }
      end
    end

    alias_method(:build_request_without_new_relic, :build_request)

    def build_request(*args)
      build_request_with_new_relic(*args) { build_request_without_new_relic(*args) }
    end
  end
end