Module: OpenTelemetry::Instrumentation::HTTPX::Plugin::RequestMethods

Defined in:
lib/opentelemetry/instrumentation/httpx/plugin.rb

Overview

Request patch to initiate the trace on initialization.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#init_timeObject

Returns the value of attribute init_time.



14
15
16
# File 'lib/opentelemetry/instrumentation/httpx/plugin.rb', line 14

def init_time
  @init_time
end

Instance Method Details

#initializeObject

intercepts request initialization to inject the tracing logic.



17
18
19
20
21
22
23
# File 'lib/opentelemetry/instrumentation/httpx/plugin.rb', line 17

def initialize(*)
  super

  @init_time = nil

  RequestTracer.call(self)
end

#response=Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/opentelemetry/instrumentation/httpx/plugin.rb', line 25

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

  super
end