Class: NewRelic::Agent::Transaction::Segment
- Inherits:
-
AbstractSegment
- Object
- AbstractSegment
- NewRelic::Agent::Transaction::Segment
- Defined in:
- lib/new_relic/agent/transaction/segment.rb
Direct Known Subclasses
DatastoreSegment, ExternalRequestSegment, MessageBrokerSegment
Constant Summary
Constants inherited from AbstractSegment
AbstractSegment::CALLBACK, AbstractSegment::INSPECT_IGNORE, AbstractSegment::SEGMENT
Instance Attribute Summary collapse
-
#custom_transaction_attributes ⇒ Object
readonly
unscoped_metrics can be nil, a string, or array.
-
#unscoped_metrics ⇒ Object
readonly
unscoped_metrics can be nil, a string, or array.
Attributes inherited from AbstractSegment
#children_time, #duration, #end_time, #exclusive_duration, #guid, #name, #noticed_error, #parent, #record_on_finish, #record_scoped_metric, #start_time, #starting_segment_key, #transaction, #transaction_name
Class Method Summary collapse
- .finish(segment) ⇒ Object
- .merge_untrusted_agent_attributes(attributes, prefix, default_destinations) ⇒ Object
Instance Method Summary collapse
- #add_agent_attribute(key, value, default_destinations = AttributeFilter::DST_SPAN_EVENTS) ⇒ Object
- #add_custom_attributes(p) ⇒ Object
- #attributes ⇒ Object
-
#initialize(name = nil, unscoped_metrics = nil, start_time = nil) ⇒ Segment
constructor
A new instance of Segment.
- #merge_untrusted_agent_attributes(agent_attributes, prefix, default_destinations) ⇒ Object
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, #start, #time_range, #transaction_assigned
Constructor Details
#initialize(name = nil, unscoped_metrics = nil, start_time = nil) ⇒ Segment
Returns a new instance of Segment.
18 19 20 21 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 18 def initialize(name = nil, unscoped_metrics = nil, start_time = nil) @unscoped_metrics = unscoped_metrics super(name, start_time) end |
Instance Attribute Details
#custom_transaction_attributes ⇒ Object (readonly)
unscoped_metrics can be nil, a string, or array. we do this to save object allocations. if allocations weren’t important then we would initialize it as an array that would be empty, have one item, or many items.
16 17 18 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 16 def custom_transaction_attributes @custom_transaction_attributes end |
#unscoped_metrics ⇒ Object (readonly)
unscoped_metrics can be nil, a string, or array. we do this to save object allocations. if allocations weren’t important then we would initialize it as an array that would be empty, have one item, or many items.
16 17 18 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 16 def unscoped_metrics @unscoped_metrics end |
Class Method Details
.finish(segment) ⇒ Object
49 50 51 52 53 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 49 def self.finish(segment) return unless segment segment.finish end |
.merge_untrusted_agent_attributes(attributes, prefix, default_destinations) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 31 def self.merge_untrusted_agent_attributes(attributes, prefix, default_destinations) if segment = NewRelic::Agent::Tracer.current_segment segment.merge_untrusted_agent_attributes(attributes, prefix, default_destinations) else NewRelic::Agent.logger.debug('Attempted to merge untrusted attributes without segment') end end |
Instance Method Details
#add_agent_attribute(key, value, default_destinations = AttributeFilter::DST_SPAN_EVENTS) ⇒ Object
27 28 29 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 27 def add_agent_attribute(key, value, default_destinations = AttributeFilter::DST_SPAN_EVENTS) attributes.add_agent_attribute(key, value, default_destinations) end |
#add_custom_attributes(p) ⇒ Object
45 46 47 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 45 def add_custom_attributes(p) attributes.merge_custom_attributes(p) end |
#attributes ⇒ Object
23 24 25 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 23 def attributes @attributes ||= Attributes.new(NewRelic::Agent.instance.attribute_filter) end |
#merge_untrusted_agent_attributes(agent_attributes, prefix, default_destinations) ⇒ Object
39 40 41 42 43 |
# File 'lib/new_relic/agent/transaction/segment.rb', line 39 def merge_untrusted_agent_attributes(agent_attributes, prefix, default_destinations) return if agent_attributes.nil? attributes.merge_untrusted_agent_attributes(agent_attributes, prefix, default_destinations) end |