Class: Datadog::Tracing::Contrib::HTTPX::Plugin::RequestTracer
- Inherits:
-
Object
- Object
- Datadog::Tracing::Contrib::HTTPX::Plugin::RequestTracer
- Includes:
- Contrib::HttpAnnotationHelper
- Defined in:
- lib/httpx/adapters/datadog.rb
Constant Summary collapse
- SPAN_REQUEST =
"httpx.request"
Instance Method Summary collapse
-
#call(*args) ⇒ Object
sets up the span start time, while preparing the on response callback.
-
#initialize(request) ⇒ RequestTracer
constructor
initializes the tracer object on the
request
.
Constructor Details
#initialize(request) ⇒ RequestTracer
initializes the tracer object on the request
.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/httpx/adapters/datadog.rb', line 39 def initialize(request) @request = request @start_time = nil # request objects are reused, when already buffered requests get rerouted to a different # connection due to connection issues, or when they already got a response, but need to # be retried. In such situations, the original span needs to be extended for the former, # while a new is required for the latter. request.on(:idle) { reset } # the span is initialized when the request is buffered in the parser, which is the closest # one gets to actually sending the request. request.on(:headers) { call } end |
Instance Method Details
#call(*args) ⇒ Object
sets up the span start time, while preparing the on response callback.
54 55 56 57 58 59 60 |
# File 'lib/httpx/adapters/datadog.rb', line 54 def call(*args) return if @start_time start(*args) @request.once(:response, &method(:finish)) end |