Class: TingYun::Agent::Transaction::RequestAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/agent/transaction/request_attributes.rb

Constant Summary collapse

HTTP_ACCEPT_HEADER_KEY =
'HTTP_ACCEPT'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ RequestAttributes

Returns a new instance of RequestAttributes.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 15

def initialize request
  @header = request.env
  @request_path = path_from_request request
  @referer = referer_from_request request
  @accept = attribute_from_env request, HTTP_ACCEPT_HEADER_KEY
  @content_length = content_length_from_request request
  @host = attribute_from_request request, :host
  @port = port_from_request request
  @user_agent = attribute_from_request request, :user_agent
  @request_method = attribute_from_request request, :request_method
  @cookie = set_cookie(request)
end

Instance Attribute Details

#acceptObject (readonly)

Returns the value of attribute accept.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def accept
  @accept
end

#content_lengthObject (readonly)

Returns the value of attribute content_length.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def content_length
  @content_length
end

Returns the value of attribute cookie.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def cookie
  @cookie
end

#headerObject (readonly)

Returns the value of attribute header.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def header
  @header
end

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def port
  @port
end

#refererObject (readonly)

Returns the value of attribute referer.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def referer
  @referer
end

#request_methodObject (readonly)

Returns the value of attribute request_method.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def request_method
  @request_method
end

#request_pathObject (readonly)

Returns the value of attribute request_path.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def request_path
  @request_path
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



10
11
12
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 10

def user_agent
  @user_agent
end

Instance Method Details

#assign_agent_attributes(attributes) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 28

def assign_agent_attributes(attributes)
  attributes.add_agent_attribute :request_path, request_path
  attributes.add_agent_attribute :referer, referer
  attributes.add_agent_attribute :accept, accept
  attributes.add_agent_attribute :contentLength, content_length
  attributes.add_agent_attribute :host, host
  attributes.add_agent_attribute :port, port
  attributes.add_agent_attribute :userAgent, user_agent
  attributes.add_agent_attribute :method, request_method
end