Module: HTTPX::Plugins::Tracing::RequestMethods
- Defined in:
- lib/httpx/plugins/tracing.rb
Instance Attribute Summary collapse
-
#init_time ⇒ Object
Returns the value of attribute init_time.
Instance Method Summary collapse
-
#initialize ⇒ Object
intercepts request initialization to inject the tracing logic.
- #response= ⇒ Object
Instance Attribute Details
#init_time ⇒ Object
Returns the value of attribute init_time.
66 67 68 |
# File 'lib/httpx/plugins/tracing.rb', line 66 def init_time @init_time end |
Instance Method Details
#initialize ⇒ Object
intercepts request initialization to inject the tracing logic.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/httpx/plugins/tracing.rb', line 69 def initialize(*) super @init_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 = nil 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 ||= ::Time.now.utc tracer.start(self) end on(:response) { |response| tracer.finish(self, response) } end |
#response= ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/httpx/plugins/tracing.rb', line 94 def response=(*) # init_time should be set when it's send to a connection. # However, 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 ||= ::Time.now.utc super end |