Module: Datadog::Tracing::Contrib::HTTPX::Plugin::RequestMethods

Defined in:
lib/httpx/adapters/datadog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#init_timeObject

Returns the value of attribute init_time.



183
184
185
# File 'lib/httpx/adapters/datadog.rb', line 183

def init_time
  @init_time
end

Instance Method Details

#initializeObject

intercepts request initialization to inject the tracing logic.



186
187
188
189
190
191
192
193
194
# File 'lib/httpx/adapters/datadog.rb', line 186

def initialize(*)
  super

  @init_time = nil

  return unless Datadog::Tracing.enabled?

  RequestTracer.call(self)
end

#response=Object



196
197
198
199
200
201
202
203
204
205
# File 'lib/httpx/adapters/datadog.rb', line 196

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 ||= ::Datadog::Core::Utils::Time.now.utc

  super
end