Class: StackifyRubyAPM::Spies::CurbSpy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify_apm/spies/curb.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
38
39
40
41
42
43
# File 'lib/stackify_apm/spies/curb.rb', line 10

def install
  Curl.module_eval do
    singleton_class.send(:alias_method, :http_without_apm, :http)
    def self.http(verb, url, _post_body = nil, _put_data = nil, &block)
      req = nil
      return http_without_apm(verb, url, _post_body = nil, _put_data = nil, &block) unless StackifyRubyAPM.current_transaction
      # Data configuration
      #
      method = verb
      uri = url.strip
      name = "#{method} #{uri}"
      type = "ext.Curb.#{method}"
      # Submits HTTP request
      #
      req = http_without_apm(verb, url, _post_body = nil, _put_data = nil, &block)
      # Builds span context
      #
      status_code = req.status.sub(/^0-9/, '').to_i

      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
        req
      end
    end
  end
end