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