class Datadog::Tracing::Contrib::HTTPX::Plugin::RequestTracer

  1. lib/httpx/adapters/datadog.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. call

Included modules

  1. Contrib::HttpAnnotationHelper

Constants

SPAN_REQUEST = "httpx.request"  

Public Class methods

new(request)

initializes the tracer object on the request.

[show source]
   # File lib/httpx/adapters/datadog.rb
39 def initialize(request)
40   @request = request
41   @start_time = nil
42 
43   # request objects are reused, when already buffered requests get rerouted to a different
44   # connection due to connection issues, or when they already got a response, but need to
45   # be retried. In such situations, the original span needs to be extended for the former,
46   # while a new is required for the latter.
47   request.on(:idle) { reset }
48   # the span is initialized when the request is buffered in the parser, which is the closest
49   # one gets to actually sending the request.
50   request.on(:headers) { call }
51 end

Public Instance methods

call(*args)

sets up the span start time, while preparing the on response callback.

[show source]
   # File lib/httpx/adapters/datadog.rb
54 def call(*args)
55   return if @start_time
56 
57   start(*args)
58 
59   @request.once(:response, &method(:finish))
60 end