Class: Timber::Integrations::Rack::HTTPResponse
- Inherits:
-
Object
- Object
- Timber::Integrations::Rack::HTTPResponse
- Defined in:
- lib/timber-rack/http_response.rb
Overview
The HTTP server response event tracks outgoing HTTP responses that you send to clients.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content_length ⇒ Object
readonly
Returns the value of attribute content_length.
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#headers_json ⇒ Object
readonly
Returns the value of attribute headers_json.
-
#http_context ⇒ Object
readonly
Returns the value of attribute http_context.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ HTTPResponse
constructor
A new instance of HTTPResponse.
-
#message ⇒ Object
Returns the human readable log message for this event.
- #status_description ⇒ Object
Constructor Details
#initialize(attributes) ⇒ HTTPResponse
Returns a new instance of HTTPResponse.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/timber-rack/http_response.rb', line 11 def initialize(attributes) @body = attributes[:body] @content_length = attributes[:content_length] @headers = attributes[:headers] @http_context = attributes[:http_context] @request_id = attributes[:request_id] @service_name = attributes[:service_name] @status = attributes[:status] @duration_ms = attributes[:duration_ms] if @headers @headers_json = @headers.to_json end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def body @body end |
#content_length ⇒ Object (readonly)
Returns the value of attribute content_length.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def content_length @content_length end |
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def duration_ms @duration_ms end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def headers @headers end |
#headers_json ⇒ Object (readonly)
Returns the value of attribute headers_json.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def headers_json @headers_json end |
#http_context ⇒ Object (readonly)
Returns the value of attribute http_context.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def http_context @http_context end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def request_id @request_id end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def service_name @service_name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/timber-rack/http_response.rb', line 8 def status @status end |
Instance Method Details
#message ⇒ Object
Returns the human readable log message for this event.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/timber-rack/http_response.rb', line 27 def if http_context = "#{http_context[:method]} #{http_context[:path]} completed with " \ "#{status} #{status_description} " if content_length << ", #{content_length} bytes, " end << "in #{duration_ms}ms" else = "Completed #{status} #{status_description} " if content_length << ", #{content_length} bytes, " end << "in #{duration_ms}ms" end end |
#status_description ⇒ Object
48 49 50 |
# File 'lib/timber-rack/http_response.rb', line 48 def status_description ::Rack::Utils::HTTP_STATUS_CODES[status] end |