Module: FaradayPatch::HeliosFaradayMiddleware

Defined in:
lib/helios/opentelemetry/sdk/patches/faraday_patch.rb

Instance Method Summary collapse

Instance Method Details

#extract_additional_attributes(span, env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/helios/opentelemetry/sdk/patches/faraday_patch.rb', line 12

def extract_additional_attributes(span, env)
  request_headers = env.request_headers
  semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
  span.set_attribute(semantic_attributes::HTTP_REQUEST_HEADERS, request_headers.to_json)
  span.set_attribute(semantic_attributes::HTTP_REQUEST_BODY, env.body) unless env.body.nil?
  response_headers = env.response_headers
  span.set_attribute(semantic_attributes::HTTP_RESPONSE_HEADERS, response_headers.to_json)
  span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, env.response_body) unless env.response_body.nil?
rescue StandardError => e
  ::OpenTelemetry.logger.debug("Error extracting faraday attributes: #{e}")
end

#trace_response(span, env) ⇒ Object



7
8
9
10
# File 'lib/helios/opentelemetry/sdk/patches/faraday_patch.rb', line 7

def trace_response(span, env)
  extract_additional_attributes(span, env)
  super(span, env)
end