lib/timber/contexts/http.rb in timber-2.0.24 vs lib/timber/contexts/http.rb in timber-2.1.0.rc1
- old
+ new
@@ -1,10 +1,16 @@
+require "timber/context"
+
module Timber
module Contexts
- # The HTTP content tracks the current HTTP request being processed. This serves
- # as join data across your logs, allowing you to query all logs for any attribute
- # presented here. For example, viewing all logs for a given request_id.
+ # The HTTP context adds data about the current HTTP request being processed to your logs.
+ # This allows your to tail and filter by this data. A very useful piece of data this
+ # captures is the request ID. This gives you the ability to trace requests and view logs
+ # for a specific request only. For example, say you've searched your logs and found the
+ # specific line you are looking for, but it lacks context. With Timber you can simply
+ # click the request ID and "zoom out" to view all logs for that request. This gives you
+ # complete picture of how the log line in questio was generated.
#
# @note This context should be installed automatically through integrations,
# such as the {Intregrations::Rack::HTTPContext} rack middleware.
class HTTP < Context
@keyspace = :http
@@ -16,9 +22,10 @@
@path = attributes[:path] || raise(ArgumentError.new(":path is required"))
@remote_addr = attributes[:remote_addr]
@request_id = attributes[:request_id]
end
+ # Builds a hash representation of containing simply objects, suitable for serialization.
def as_json(_options = {})
{:method => method, :path => path, :remote_addr => remote_addr, :request_id => request_id}
end
end
end
\ No newline at end of file