Class: Timber::Contexts::HTTP
- Inherits:
-
Timber::Context
- Object
- Timber::Context
- Timber::Contexts::HTTP
- Defined in:
- lib/timber/contexts/http.rb
Overview
Note:
This context should be installed automatically through probes, such as the Probes::RackHTTPContext probe.
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.
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#remote_addr ⇒ Object
readonly
Returns the value of attribute remote_addr.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ HTTP
constructor
A new instance of HTTP.
Constructor Details
#initialize(attributes) ⇒ HTTP
Returns a new instance of HTTP.
14 15 16 17 18 19 |
# File 'lib/timber/contexts/http.rb', line 14 def initialize(attributes) @method = attributes[:method] || raise(ArgumentError.new(":method is required")) @path = attributes[:path] || raise(ArgumentError.new(":path is required")) @remote_addr = attributes[:remote_addr] @request_id = attributes[:request_id] end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
12 13 14 |
# File 'lib/timber/contexts/http.rb', line 12 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/timber/contexts/http.rb', line 12 def path @path end |
#remote_addr ⇒ Object (readonly)
Returns the value of attribute remote_addr.
12 13 14 |
# File 'lib/timber/contexts/http.rb', line 12 def remote_addr @remote_addr end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
12 13 14 |
# File 'lib/timber/contexts/http.rb', line 12 def request_id @request_id end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
21 22 23 |
# File 'lib/timber/contexts/http.rb', line 21 def as_json( = {}) {:method => method, :path => path, :remote_addr => remote_addr, :request_id => request_id} end |