module Datadog::Tracing::Contrib::HTTPX::Plugin::ConnectionMethods

  1. lib/httpx/adapters/datadog.rb

Methods

Public Class

  1. new

Public Instance

  1. handle_error
  2. init_time

Attributes

init_time [R]

Public Class methods

new(*)
[show source]
    # File lib/httpx/adapters/datadog.rb
188 def initialize(*)
189   super
190 
191   @init_time = ::Datadog::Core::Utils::Time.now.utc
192 end

Public Instance methods

handle_error(error, request = nil)

handles the case when the error happened during name resolution, which meanns that the tracing logic hasn’t been injected yet; in such cases, the approximate initial resolving time is collected from the connection, and used as span start time, and the tracing object in inserted before the on response callback is called.

[show source]
    # File lib/httpx/adapters/datadog.rb
198 def handle_error(error, request = nil)
199   return super unless Datadog::Tracing.enabled?
200 
201   return super unless error.respond_to?(:connection)
202 
203   @pending.each do |req|
204     next if request and request == req
205 
206     RequestTracer.new(req).call(error.connection.init_time)
207   end
208 
209   RequestTracer.new(request).call(error.connection.init_time) if request
210 
211   super
212 end