Class: StackifyRubyAPM::Spies::CurbMultiSpy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify_apm/spies/curb/multi.rb

Overview

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

API:

  • private

Instance Method Summary collapse

Instance Method Details

#installObject

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.

API:

  • private



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/stackify_apm/spies/curb/multi.rb', line 10

def install
  Curl::Multi.class_eval do
    singleton_class.send(:alias_method, :http_without_apm, :http)

    def self.http(urls_with_config, _multi_options = {}, &blk)
      return http_without_apm(urls_with_config, _multi_options = {}, &blk) unless StackifyRubyAPM.current_transaction
      http_without_apm(urls_with_config, _multi_options = {}) do |c, code, method|
        status_code = code.zero? ? 404 : code
        method = method.upcase
        uri = c.url.to_s.strip
        name = "#{method} #{uri}"
        type = "ext.Curb.Multi.#{method}"

        ctx = Span::Context.new(
          CATEGORY: 'Web External',
          SUBCATEGORY: 'Execute',
          URL: uri,
          STATUS: status_code,
          METHOD: method
        )
        # Creates new span from HTTP result
        StackifyRubyAPM.span name, type, context: ctx do
          blk.call(c, code, method)
        end
      end
    end
  end
end