Class: NewRelic::Agent::Transaction::RequestAttributes
- Inherits:
-
Object
- Object
- NewRelic::Agent::Transaction::RequestAttributes
- Defined in:
- lib/new_relic/agent/transaction/request_attributes.rb
Constant Summary collapse
- HTTP_ACCEPT_HEADER_KEY =
'HTTP_ACCEPT'.freeze
- BASE_HEADERS =
%w[CONTENT_LENGTH CONTENT_TYPE HTTP_ACCEPT HTTP_REFERER HTTP_USER_AGENT PATH_INFO REMOTE_HOST REQUEST_METHOD REQUEST_URI SERVER_PORT].freeze
- ATTRIBUTE_PREFIX =
'request.headers.'
Instance Attribute Summary collapse
-
#accept ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#content_length ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#content_type ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#host ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#other_headers ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#port ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#referer ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#request_method ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#request_path ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
-
#user_agent ⇒ Object
readonly
the HTTP standard has “referrer” mispelled as “referer”.
Instance Method Summary collapse
- #assign_agent_attributes(txn) ⇒ Object
-
#initialize(request) ⇒ RequestAttributes
constructor
A new instance of RequestAttributes.
Constructor Details
#initialize(request) ⇒ RequestAttributes
Returns a new instance of RequestAttributes.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 22 def initialize(request) @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) @content_type = content_type_attribute_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) @other_headers = other_headers_from_request(request) end |
Instance Attribute Details
#accept ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def accept @accept end |
#content_length ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def content_length @content_length end |
#content_type ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def content_type @content_type end |
#host ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def host @host end |
#other_headers ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def other_headers @other_headers end |
#port ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def port @port end |
#referer ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def referer @referer end |
#request_method ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def request_method @request_method end |
#request_path ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def request_path @request_path end |
#user_agent ⇒ Object (readonly)
the HTTP standard has “referrer” mispelled as “referer”
12 13 14 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 12 def user_agent @user_agent end |
Instance Method Details
#assign_agent_attributes(txn) ⇒ Object
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/new_relic/agent/transaction/request_attributes.rb', line 35 def assign_agent_attributes(txn) default_destinations = AttributeFilter::DST_TRANSACTION_TRACER | AttributeFilter::DST_TRANSACTION_EVENTS | AttributeFilter::DST_ERROR_COLLECTOR if referer destinations = allow_other_headers? ? default_destinations : AttributeFilter::DST_ERROR_COLLECTOR txn.add_agent_attribute(:'request.headers.referer', referer, destinations) end if request_path destinations = if allow_other_headers? default_destinations else AttributeFilter::DST_TRANSACTION_TRACER | AttributeFilter::DST_ERROR_COLLECTOR end txn.add_agent_attribute(:'request.uri', request_path, destinations) end if accept txn.add_agent_attribute(:'request.headers.accept', accept, default_destinations) end if content_length txn.add_agent_attribute(:'request.headers.contentLength', content_length, default_destinations) end if content_type txn.add_agent_attribute(:'request.headers.contentType', content_type, default_destinations) end if host txn.add_agent_attribute(:'request.headers.host', host, default_destinations) end if user_agent txn.add_agent_attribute(:'request.headers.userAgent', user_agent, default_destinations) end if request_method txn.add_agent_attribute(:'request.method', request_method, default_destinations) end if port && allow_other_headers? txn.add_agent_attribute(:'request.headers.port', port, default_destinations) end other_headers.each do |header, value| txn.add_agent_attribute(header, value, default_destinations) end end |