Class: Atatus::Spies::HTTPSpy Private
- Inherits:
-
Object
- Object
- Atatus::Spies::HTTPSpy
- Defined in:
- lib/atatus/spies/http.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.
Constant Summary collapse
- TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'ext'- SUBTYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'http_rb'
Instance Method Summary collapse
- #install ⇒ Object private
Instance Method Details
#install ⇒ 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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/atatus/spies/http.rb', line 27 def install if defined?(::HTTP) && defined?(::HTTP::Client) ::HTTP::Client.class_eval do alias perform_without_apm perform def perform(req, ) unless (transaction = Atatus.current_transaction) return perform_without_apm(req, ) end method = req.verb.to_s.upcase host = req.uri.host destination = Atatus::Span::Context::Destination.from_uri(req.uri) context = Atatus::Span::Context.new( http: { url: req.uri, method: method }, destination: destination ) name = "#{method} #{host}" Atatus.with_span( name, TYPE, subtype: SUBTYPE, action: method, context: context ) do |span| trace_context = span&.trace_context || transaction.trace_context trace_context.apply_headers { |key, value| req[key] = value } result = perform_without_apm(req, ) if (http = span&.context&.http) http.status_code = result.status.to_s end result end end end end end |