Class: StackifyRubyAPM::Spies::HTTPRbSpy Private

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

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.

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.



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
# File 'lib/stackify_apm/spies/httprb.rb', line 11

def install
  HTTP::Client.class_eval do
    alias_method 'request_without_apm', 'request'

    # Make HTTP request
    def request(verb, uri, _opts = {})
      return request_without_apm(verb, uri, _opts = {}) unless StackifyRubyAPM.current_transaction

      method = verb.upcase
      uri = uri.strip
      name = "#{method} #{uri}"
      type = "ext.httprb.#{method}"

      req = request_without_apm(verb, uri, _opts = {})
      ctx = Span::Context.new(
        CATEGORY: 'Web External',
        SUBCATEGORY: 'Execute',
        URL: uri,
        STATUS: req.code,
        METHOD: method
      )

      StackifyRubyAPM.span name, type, context: ctx do
        req
      end
    end
  end
end