lib/timber/events/http_server_response.rb in timber-1.1.14 vs lib/timber/events/http_server_response.rb in timber-2.0.0
- old
+ new
@@ -1,33 +1,33 @@
module Timber
module Events
- # The HTTP response event tracks outgoing HTTP request responses.
+ # The HTTP server response event tracks outgoing HTTP responses that you send
+ # to clients.
#
- # @note This event should be installed automatically through probes,
- # such as the {Probes::ActionControllerLogSubscriber} probe.
+ # @note This event should be installed automatically through integrations,
+ # such as the {Integrations::ActionController::LogSubscriber} integration.
class HTTPServerResponse < Timber::Event
- attr_reader :status, :time_ms, :additions
+ attr_reader :headers, :request_id, :status, :time_ms
def initialize(attributes)
+ @headers = Util::HTTPEvent.normalize_headers(attributes[:headers])
+ @request_id = attributes[:request_id]
@status = attributes[:status] || raise(ArgumentError.new(":status is required"))
@time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required"))
@time_ms = @time_ms.round(6)
- @additions = attributes[:additions]
end
def to_hash
- {status: status, time_ms: time_ms}
+ {headers: headers, request_id: request_id, status: status, time_ms: time_ms}
end
alias to_h to_hash
def as_json(_options = {})
{:server_side_app => {:http_server_response => to_hash}}
end
def message
- message = "Completed #{status} #{status_description} in #{time_ms}ms"
- message << " (#{additions.join(" | ".freeze)})" unless additions.empty?
- message
+ "Completed #{status} #{status_description} in #{time_ms}ms"
end
def status_description
Rack::Utils::HTTP_STATUS_CODES[status]
end
\ No newline at end of file