Class: OpenTracing::Instrumentation::Faraday::ResponseLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/opentracing/instrumentation/faraday/response_logger.rb

Overview

ResponseLogger add request and response log_kv to faraday_request span

Constant Summary collapse

DEFAULT_REQUEST_LOG_HEADERS =
%w[].freeze
DEFAULT_REQUEST_TAG_HEADERS =
{
  accept: 'Accept',
  connection: 'Connection',
  content_type: 'Content-Type',
  user_agent: 'User-Agent',
}.freeze
DEFAULT_RESPONSE_LOG_HEADERS =
%w[
  Content-Length
].freeze
DEFAULT_RESPONSE_TAG_HEADERS =
{
  connection: 'Connection',
  content_type: 'Content-Type',
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_log_headers: DEFAULT_REQUEST_LOG_HEADERS, request_tag_headers: DEFAULT_REQUEST_TAG_HEADERS, response_tag_headers: DEFAULT_RESPONSE_TAG_HEADERS, response_log_headers: DEFAULT_RESPONSE_LOG_HEADERS) ⇒ ResponseLogger

Returns a new instance of ResponseLogger.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 28

def initialize(
  request_log_headers: DEFAULT_REQUEST_LOG_HEADERS,
  request_tag_headers: DEFAULT_REQUEST_TAG_HEADERS,
  response_tag_headers: DEFAULT_RESPONSE_TAG_HEADERS,
  response_log_headers: DEFAULT_RESPONSE_LOG_HEADERS
)
  @request_tag_headers = request_tag_headers
  @request_log_headers = request_log_headers
  @response_tag_headers = response_tag_headers
  @response_log_headers = response_log_headers
end

Instance Attribute Details

#request_log_headersObject (readonly)

Returns the value of attribute request_log_headers.



23
24
25
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 23

def request_log_headers
  @request_log_headers
end

#request_tag_headersObject (readonly)

Returns the value of attribute request_tag_headers.



23
24
25
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 23

def request_tag_headers
  @request_tag_headers
end

#response_log_headersObject (readonly)

Returns the value of attribute response_log_headers.



23
24
25
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 23

def response_log_headers
  @response_log_headers
end

#response_tag_headersObject (readonly)

Returns the value of attribute response_tag_headers.



23
24
25
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 23

def response_tag_headers
  @response_tag_headers
end

Instance Method Details

#log_request(span, request_headers) ⇒ Object



40
41
42
43
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 40

def log_request(span, request_headers)
  log_headers(span, request_headers, request_log_headers, 'request')
  tag_headers(span, request_headers, request_tag_headers, 'request')
end

#log_response(span, response_headers) ⇒ Object



45
46
47
48
# File 'lib/opentracing/instrumentation/faraday/response_logger.rb', line 45

def log_response(span, response_headers)
  log_headers(span, response_headers, response_log_headers, 'response')
  tag_headers(span, response_headers, response_tag_headers, 'response')
end