Class: Timber::Events::HTTPClientRequest
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::HTTPClientRequest
- Defined in:
- lib/timber/events/http_client_request.rb
Overview
This event should be installed automatically through integrations, such as the Integrations::NetHTTP integration.
The HTTP client request event tracks outgoing HTTP requests giving you structured insight into communication with external services.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ HTTPClientRequest
constructor
A new instance of HTTPClientRequest.
- #message ⇒ Object
- #status_description ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ HTTPClientRequest
Returns a new instance of HTTPClientRequest.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/timber/events/http_client_request.rb', line 12 def initialize(attributes) @headers = Util::HTTPEvent.normalize_headers(attributes[:headers]) @host = attributes[:host] || raise(ArgumentError.new(":host is required")) @method = Util::HTTPEvent.normalize_method(attributes[:method]) || raise(ArgumentError.new(":method is required")) @path = attributes[:path] @port = attributes[:port] @query_string = Util::HTTPEvent.normalize_query_string(attributes[:query_string]) @request_id = attributes[:request_id] @scheme = attributes[:scheme] || raise(ArgumentError.new(":scheme is required")) @service_name = attributes[:service_name] @body = Util::HTTPEvent.normalize_body(@headers["content-type"], attributes[:body]) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def port @port end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def query_string @query_string end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def request_id @request_id end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def scheme @scheme end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
9 10 11 |
# File 'lib/timber/events/http_client_request.rb', line 9 def service_name @service_name end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
33 34 35 |
# File 'lib/timber/events/http_client_request.rb', line 33 def as_json( = {}) {:server_side_app => {:http_client_request => to_hash}} end |
#message ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/timber/events/http_client_request.rb', line 37 def = 'Outgoing HTTP request to ' if service_name mesage << " #{service_name} [#{method}] #{full_path}" else << " [#{method}] #{full_url}" end end |
#status_description ⇒ Object
47 48 49 |
# File 'lib/timber/events/http_client_request.rb', line 47 def status_description Rack::Utils::HTTP_STATUS_CODES[status] end |
#to_hash ⇒ Object Also known as: to_h
26 27 28 29 30 |
# File 'lib/timber/events/http_client_request.rb', line 26 def to_hash {headers: headers, host: host, method: method, parsed_body_json: parsed_body_json, path: path, port: port, query_string: query_string, request_id: request_id, scheme: scheme, service_name: service_name} end |