Class: Logtail::Integrations::Rack::HTTPResponse
- Inherits:
-
Object
- Object
- Logtail::Integrations::Rack::HTTPResponse
- Defined in:
- lib/logtail-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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/logtail-rack/http_response.rb', line 13 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 = Util::Encoding.force_utf8_encoding(@headers).to_json end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def body @body end |
#content_length ⇒ Object (readonly)
Returns the value of attribute content_length.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def content_length @content_length end |
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def duration_ms @duration_ms end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def headers @headers end |
#headers_json ⇒ Object (readonly)
Returns the value of attribute headers_json.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def headers_json @headers_json end |
#http_context ⇒ Object (readonly)
Returns the value of attribute http_context.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def http_context @http_context end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def request_id @request_id end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def service_name @service_name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/logtail-rack/http_response.rb', line 10 def status @status end |
Instance Method Details
#message ⇒ Object
Returns the human readable log message for this event.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/logtail-rack/http_response.rb', line 29 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
50 51 52 |
# File 'lib/logtail-rack/http_response.rb', line 50 def status_description ::Rack::Utils::HTTP_STATUS_CODES[status] end |