Sha256: 55ee0ffc634f824451112d2effa138f3c21790fcd1c73bd4c713a668f26a0ceb

Contents?: true

Size: 1011 Bytes

Versions: 5

Compression:

Stored size: 1011 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 probes,
    #   such as the {Probes::RackHTTPContext} probe.
    class HTTP < Context
      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 keyspace
        :http
      end

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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
timber-1.0.3 lib/timber/contexts/http.rb
timberio-1.0.3 lib/timber/contexts/http.rb
timberio-1.0.2 lib/timber/contexts/http.rb
timberio-1.0.1 lib/timber/contexts/http.rb
timberio-1.0.0 lib/timber/contexts/http.rb