Module: Atatus::Spies::S3Spy::Ext Private

Defined in:
lib/atatus/spies/s3.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.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/atatus/spies/s3.rb', line 81

def self.prepended(mod)
  # Alias all available operations
  mod.api.operation_names.each do |operation_name|
    define_method(operation_name) do |params = {}, options = {}, &block|
      bucket_name = Atatus::Spies::S3Spy.bucket_name(params)
      region = Atatus::Spies::S3Spy.accesspoint_region(params) || config.region

      resource = "#{SUBTYPE}/#{bucket_name || 'unknown-bucket'}"
      context = Atatus::Span::Context.new(
        db: {
          instance: config.region,
          type: SUBTYPE
        },
        destination: {
          address: config.endpoint.host,
          port: config.endpoint.port,
          service: {
            name: SUBTYPE,
            type: TYPE,
            resource: resource },
          cloud: { region: region }
        }
      )

      Atatus.with_span(
        Atatus::Spies::S3Spy.span_name(operation_name, bucket_name),
        TYPE,
        subtype: SUBTYPE,
        action: Atatus::Spies::S3Spy.formatted_op_name(operation_name),
        context: context
      ) do
        Atatus::Spies::S3Spy.without_net_http do
          super(params, options, &block)
        end
      end
    end
  end
end