Class: NewRelic::Agent::Transaction::ExternalRequestSegment
- Inherits:
-
Segment
- Object
- AbstractSegment
- Segment
- NewRelic::Agent::Transaction::ExternalRequestSegment
- Defined in:
- lib/new_relic/agent/transaction/external_request_segment.rb
Overview
This class represents an external segment in a transaction trace.
Constant Summary collapse
- NR_SYNTHETICS_HEADER =
'X-NewRelic-Synthetics'- NR_SYNTHETICS_INFO_HEADER =
'X-NewRelic-Synthetics-Info'- APP_DATA_KEY =
'NewRelicAppData'- EXTERNAL_ALL =
'External/all'- EXTERNAL_ALL_WEB =
'External/allWeb'- EXTERNAL_ALL_OTHER =
'External/allOther'- MISSING_STATUS_CODE =
'MissingHTTPStatusCode'
Constants inherited from AbstractSegment
AbstractSegment::CALLBACK, AbstractSegment::INSPECT_IGNORE, AbstractSegment::SEGMENT
Instance Attribute Summary collapse
- #http_status_code ⇒ Object readonly
- #library ⇒ Object readonly
- #procedure ⇒ Object readonly
- #uri ⇒ Object readonly
Attributes inherited from Segment
#custom_transaction_attributes, #unscoped_metrics
Attributes inherited from AbstractSegment
#children_time, #duration, #end_time, #exclusive_duration, #guid, #llm_event, #noticed_error, #parent, #record_on_finish, #record_scoped_metric, #start_time, #starting_segment_key, #thread_id, #transaction, #transaction_name
Instance Method Summary collapse
-
#add_request_headers(request) ⇒ Object
This method adds New Relic request headers to a given request made to an external API and checks to see if a host header is used for the request.
-
#host ⇒ Object
:nodoc:.
-
#initialize(library, uri, procedure, start_time = nil) ⇒ ExternalRequestSegment
constructor
:nodoc:.
-
#name ⇒ Object
:nodoc:.
-
#process_response_headers(response) ⇒ Object
:nodoc:.
- #record_metrics ⇒ Object
Methods inherited from Segment
#add_agent_attribute, #add_custom_attributes, #attributes, finish, merge_untrusted_agent_attributes, #merge_untrusted_agent_attributes
Methods inherited from AbstractSegment
#all_code_information_present?, #children_time_ranges?, #code_attributes, #code_information=, #concurrent_children?, #finalize, #finish, #finished?, #inspect, #notice_error, #noticed_error_attributes, #params, #params?, #record_metrics?, #record_on_finish?, #record_scoped_metric?, #set_noticed_error, set_segment_callback, #start, #time_range, #transaction_assigned
Constructor Details
#initialize(library, uri, procedure, start_time = nil) ⇒ ExternalRequestSegment
:nodoc:
27 28 29 30 31 32 33 34 35 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 27 def initialize(library, uri, procedure, start_time = nil) # :nodoc: @library = library @uri = HTTPClients::URIUtil.(uri) @procedure = procedure @host_header = nil @app_data = nil @http_status_code = nil super(nil, nil, start_time) end |
Instance Attribute Details
#http_status_code ⇒ Object (readonly)
25 26 27 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 25 def http_status_code @http_status_code end |
#library ⇒ Object (readonly)
25 26 27 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 25 def library @library end |
#procedure ⇒ Object (readonly)
25 26 27 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 25 def procedure @procedure end |
#uri ⇒ Object (readonly)
25 26 27 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 25 def uri @uri end |
Instance Method Details
#add_request_headers(request) ⇒ Object
This method adds New Relic request headers to a given request made to an external API and checks to see if a host header is used for the request. If a host header is used, it updates the segment name to match the host header.
object (must belong to a subclass of NewRelic::Agent::HTTPClients::AbstractRequest)
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 54 def add_request_headers(request) process_host_header(request) synthetics_header = transaction&.raw_synthetics_header synthetics_info_header = transaction&.raw_synthetics_info_header insert_synthetics_header(request, synthetics_header, synthetics_info_header) if synthetics_header return unless record_metrics? transaction.distributed_tracer.insert_headers(request) rescue => e NewRelic::Agent.logger.error('Error in add_request_headers', e) end |
#host ⇒ Object
:nodoc:
41 42 43 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 41 def host # :nodoc: @host_header || uri.host end |
#name ⇒ Object
:nodoc:
37 38 39 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 37 def name # :nodoc: @name ||= "External/#{host}/#{library}/#{procedure}" end |
#process_response_headers(response) ⇒ Object
:nodoc:
72 73 74 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 72 def process_response_headers(response) # :nodoc: set_http_status_code(response) end |
#record_metrics ⇒ Object
67 68 69 70 |
# File 'lib/new_relic/agent/transaction/external_request_segment.rb', line 67 def record_metrics add_unscoped_metrics super end |