Class: Timber::Events::HTTPRequest
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::HTTPRequest
- Defined in:
- lib/timber/events/http_request.rb
Overview
This event should be installed automatically through integrations, such as the Integrations::ActionController::LogSubscriber integration.
The HTTP server request event tracks incoming HTTP requests to your HTTP server. Such as unicorn, webrick, puma, etc.
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
Builds a hash representation containing simple objects, suitable for serialization (JSON).
-
#initialize(attributes) ⇒ HTTPRequest
constructor
A new instance of HTTPRequest.
- #message ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ HTTPRequest
Returns a new instance of HTTPRequest.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/timber/events/http_request.rb', line 15 def initialize(attributes) @body = attributes[:body] && Util::HTTPEvent.normalize_body(attributes[:body]) @headers = Util::HTTPEvent.normalize_headers(attributes[:headers]) @host = attributes[:host] @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]) @scheme = attributes[:scheme] @request_id = attributes[:request_id] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def port @port end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def query_string @query_string end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def request_id @request_id end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def scheme @scheme end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
12 13 14 |
# File 'lib/timber/events/http_request.rb', line 12 def service_name @service_name end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
34 35 36 |
# File 'lib/timber/events/http_request.rb', line 34 def as_json( = {}) {:http_request => to_hash} end |
#message ⇒ Object
38 39 40 |
# File 'lib/timber/events/http_request.rb', line 38 def 'Started %s "%s"' % [method, path] end |
#to_hash ⇒ Object Also known as: to_h
27 28 29 30 |
# File 'lib/timber/events/http_request.rb', line 27 def to_hash {body: body, headers: headers, host: host, method: method, path: path, port: port, query_string: query_string, request_id: request_id, scheme: scheme} end |