Module: ElasticAPM::Spies::DynamoDBSpy::Ext Private

Defined in:
lib/elastic_apm/spies/dynamo_db.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.prepended(mod) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/elastic_apm/spies/dynamo_db.rb', line 55

def self.prepended(mod)
  # Alias all available operations
  mod.api.operation_names.each do |operation_name|
    define_method(operation_name) do |params = {}, options = {}|
      context = ElasticAPM::Span::Context.new(
        db: {
          instance: config.region,
          type: SUBTYPE,
          statement: params[:key_condition_expression]
        },
        destination: {
          address: config.endpoint.host,
          port: config.endpoint.port,
          service: {
              name: SUBTYPE,
              type: TYPE,
              resource: SUBTYPE },
          cloud: { region: config.region }
        }
      )

      ElasticAPM.with_span(
        ElasticAPM::Spies::DynamoDBSpy.span_name(operation_name, params),
        TYPE,
        subtype: SUBTYPE,
        action: ACTION,
        context: context
      ) do
        ElasticAPM::Spies::DynamoDBSpy.without_net_http do
          super(params, options)
        end
      end
    end
  end
end