Attributes
| init_time | [RW] |
Public Class methods
new(*)
intercepts request initialization to inject the tracing logic.
[show source]
# File lib/httpx/plugins/tracing.rb 74 def initialize(*) 75 super 76 77 @init_time = nil 78 79 tracer = @options.tracer 80 81 return unless tracer && tracer.enabled?(self) 82 83 on(:idle) do 84 tracer.reset(self) 85 86 # request is reset when it's retried. 87 @init_time = nil 88 end 89 on(:headers) do 90 # the usual request init time (when not including the connection handshake) 91 # should be the time the request is buffered the first time. 92 @init_time ||= ::Time.now.utc 93 94 tracer.start(self) 95 end 96 on(:response) { |response| tracer.finish(self, response) } 97 end
Public Instance methods
response=(*)
[show source]
# File lib/httpx/plugins/tracing.rb 99 def response=(*) 100 # init_time should be set when it's send to a connection. 101 # However, there are situations where connection initialization fails. 102 # Example is the :ssrf_filter plugin, which raises an error on 103 # initialize if the host is an IP which matches against the known set. 104 # in such cases, we'll just set here right here. 105 @init_time ||= ::Time.now.utc 106 107 super 108 end