Module: HTTPX::Plugins::Tracing::RequestMethods
- Defined in:
- lib/httpx/plugins/tracing.rb,
sig/plugins/tracing.rbs
Instance Attribute Summary collapse
-
#enqueue_time ⇒ Time?
time at which the request was first handed to a connection, or last moved back to waiting for one.
-
#handshake_time ⇒ Float?
when not nil, it means this request was sent to a non-open connection, and contains how much time it took the connection to connect.
-
#init_time ⇒ Time?
time at which a request started being buffered for sending.
Instance Method Summary collapse
-
#initialize ⇒ Object
intercepts request initialization to inject the tracing logic.
- #response= ⇒ Object
Instance Attribute Details
#enqueue_time ⇒ Time?
time at which the request was first handed to a connection, or last moved back to waiting for one.
74 75 76 |
# File 'lib/httpx/plugins/tracing.rb', line 74 def enqueue_time @enqueue_time end |
#handshake_time ⇒ Float?
when not nil, it means this request was sent to a non-open connection, and contains how much time it took the connection to connect.
71 72 73 |
# File 'lib/httpx/plugins/tracing.rb', line 71 def handshake_time @handshake_time end |
#init_time ⇒ Time?
time at which a request started being buffered for sending.
67 68 69 |
# File 'lib/httpx/plugins/tracing.rb', line 67 def init_time @init_time end |
Instance Method Details
#initialize ⇒ Object
intercepts request initialization to inject the tracing logic.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/httpx/plugins/tracing.rb', line 77 def initialize(*) super @init_time = @handshake_time = @enqueue_time = nil tracer = @options.tracer return unless tracer && tracer.enabled?(self) on(:idle) do tracer.reset(self) # request is reset when it's retried. @init_time = @handshake_time = nil # going back to idle means waiting to be sent again. @enqueue_time = ::Time.now.utc end on(:headers) do # the usual request init time (when not including the connection handshake) # should be the time the request is buffered the first time. @init_time = calculate_init_time tracer.start(self) end on(:response) { |response| tracer.finish(self, response) } end |
#response= ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/httpx/plugins/tracing.rb', line 105 def response=(*) # There are situations where connection initialization fails. # Example is the :ssrf_filter plugin, which raises an error on # initialize if the host is an IP which matches against the known set. # in such cases, we'll just set here right here. @init_time ||= calculate_init_time super end |