Sha256: 89a2e065467d9476aa4f1cf07ecf6a69ec0337698a07b50268a594ceac841599

Contents?: true

Size: 1017 Bytes

Versions: 23

Compression:

Stored size: 1017 Bytes

Contents

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.
    #
    # @note This context should be installed automatically through integrations,
    #   such as the {Intregrations::Rack::HTTPContext} rack middleware.
    class HTTP < Context
      @keyspace = :http

      attr_reader :method, :path, :remote_addr, :request_id

      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

      def as_json(_options = {})
        {:method => method, :path => path, :remote_addr => remote_addr, :request_id => request_id}
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/contexts/http.rb
timber-2.0.23 lib/timber/contexts/http.rb
timber-2.0.22 lib/timber/contexts/http.rb
timber-2.0.21 lib/timber/contexts/http.rb
timber-2.0.20 lib/timber/contexts/http.rb
timber-2.0.19 lib/timber/contexts/http.rb
timber-2.0.17 lib/timber/contexts/http.rb
timber-2.0.16 lib/timber/contexts/http.rb
timber-2.0.15 lib/timber/contexts/http.rb
timber-2.0.14 lib/timber/contexts/http.rb
timber-2.0.12 lib/timber/contexts/http.rb
timber-2.0.11 lib/timber/contexts/http.rb
timber-2.0.10 lib/timber/contexts/http.rb
timber-2.0.9 lib/timber/contexts/http.rb
timber-2.0.8 lib/timber/contexts/http.rb
timber-2.0.7 lib/timber/contexts/http.rb
timber-2.0.6 lib/timber/contexts/http.rb
timber-2.0.5 lib/timber/contexts/http.rb
timber-2.0.4 lib/timber/contexts/http.rb
timber-2.0.3 lib/timber/contexts/http.rb