module OpenTelemetry::Adapters::Ethon::Patches::Easy
Ethon::Easy patch for instrumentation
Constants
- ACTION_NAMES_TO_HTTP_METHODS
- HTTP_METHODS_TO_SPAN_NAMES
Public Instance Methods
complete()
click to toggle source
Calls superclass method
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 35 def complete # rubocop:disable Metrics/MethodLength begin response_options = mirror.options response_code = (response_options[:response_code] || response_options[:code]).to_i if response_code.zero? return_code = response_options[:return_code] message = return_code ? ::Ethon::Curl.easy_strerror(return_code) : 'unknown reason' @otel_span.status = OpenTelemetry::Trace::Status.new( OpenTelemetry::Trace::Status::UNKNOWN_ERROR, description: "Request has failed: #{message}" ) else @otel_span.set_attribute('http.status_code', response_code) @otel_span.status = OpenTelemetry::Trace::Status.http_to_status( response_code ) end ensure @otel_span.finish @otel_span = nil end super end
headers=(headers)
click to toggle source
Calls superclass method
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 24 def headers=(headers) # Store headers to call this method again when span is ready @otel_original_headers = headers super end
http_request(url, action_name, options = {})
click to toggle source
Calls superclass method
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 19 def http_request(url, action_name, options = {}) @otel_method = ACTION_NAMES_TO_HTTP_METHODS[action_name] super end
otel_before_request()
click to toggle source
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 67 def otel_before_request method = 'N/A' # Could be GET or not HTTP at all method = @otel_method if instance_variable_defined?(:@otel_method) && !@otel_method.nil? @otel_span = tracer.start_span( HTTP_METHODS_TO_SPAN_NAMES[method], attributes: { 'component' => 'http', 'http.method' => method, 'http.url' => url }, kind: :client ) @otel_original_headers ||= {} tracer.with_span(@otel_span) do OpenTelemetry.propagation.http.inject(@otel_original_headers) end self.headers = @otel_original_headers end
otel_span_started?()
click to toggle source
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 88 def otel_span_started? instance_variable_defined?(:@otel_span) && !@otel_span.nil? end
perform()
click to toggle source
Calls superclass method
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 30 def perform otel_before_request super end
reset()
click to toggle source
Calls superclass method
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 59 def reset super ensure @otel_span = nil @otel_method = nil @otel_original_headers = nil end
Private Instance Methods
tracer()
click to toggle source
# File lib/opentelemetry/adapters/ethon/patches/easy.rb, line 94 def tracer Ethon::Adapter.instance.tracer end