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(txn) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ting_yun/agent/transaction/request_attributes.rb', line 28

def assign_agent_attributes(txn)

  if request_path
    txn.add_agent_attribute :request_path, request_path
  end

  if referer
    txn.add_agent_attribute :referer, referer
  end

  if accept
    txn.add_agent_attribute :accept, accept
  end

  if content_length
    txn.add_agent_attribute :contentLength, content_length
  end

  if host
    txn.add_agent_attribute :host, host
  end

  if port
    txn.add_agent_attribute :port, port
  end

  if user_agent
    txn.add_agent_attribute :userAgent, user_agent
  end

  if request_method
    txn.add_agent_attribute :method, request_method
  end


end