Class: Logtail::Contexts::HTTP

Inherits:
Logtail::Context show all
Defined in:
lib/logtail/contexts/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ HTTP

Returns a new instance of HTTP.



9
10
11
12
13
14
15
# File 'lib/logtail/contexts/http.rb', line 9

def initialize(attributes)
  @host = attributes[:host]
  @method = attributes[:method]
  @path = attributes[:path]
  @remote_addr = attributes[:remote_addr]
  @request_id = attributes[:request_id]
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/logtail/contexts/http.rb', line 7

def host
  @host
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/logtail/contexts/http.rb', line 7

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/logtail/contexts/http.rb', line 7

def path
  @path
end

#remote_addrObject (readonly)

Returns the value of attribute remote_addr.



7
8
9
# File 'lib/logtail/contexts/http.rb', line 7

def remote_addr
  @remote_addr
end

#request_idObject (readonly)

Returns the value of attribute request_id.



7
8
9
# File 'lib/logtail/contexts/http.rb', line 7

def request_id
  @request_id
end

Instance Method Details

#to_hashObject

Builds a hash representation containing simple objects, suitable for serialization (JSON).



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/logtail/contexts/http.rb', line 18

def to_hash
  @to_hash ||= {
    http: Util::NonNilHashBuilder.build do |h|
      h.add(:host, host)
      h.add(:method, method)
      h.add(:path, path)
      h.add(:remote_addr, remote_addr)
      h.add(:request_id, request_id)
    end
  }
end