Class: ElasticAPM::Span Private
- Inherits:
-
Object
- Object
- ElasticAPM::Span
- Extended by:
- Forwardable
- Includes:
- ChildDurations::Methods
- Defined in:
- lib/elastic_apm/span.rb,
lib/elastic_apm/span/context.rb,
lib/elastic_apm/span/context/db.rb,
lib/elastic_apm/span/context/http.rb,
lib/elastic_apm/span/context/message.rb,
lib/elastic_apm/span/context/destination.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Constant Summary collapse
- DEFAULT_TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'custom'
Instance Attribute Summary collapse
- #action ⇒ Object private
- #context ⇒ Object readonly private
- #duration ⇒ Object readonly private
- #name ⇒ Object private
- #original_backtrace ⇒ Object private
- #outcome ⇒ Object private
- #parent ⇒ Object readonly private
- #sample_rate ⇒ Object readonly private
- #self_time ⇒ Object readonly private
- #stacktrace ⇒ Object readonly private
- #subtype ⇒ Object private
- #timestamp ⇒ Object readonly private
- #trace_context ⇒ Object private
- #transaction ⇒ Object readonly private
- #type ⇒ Object private
Instance Method Summary collapse
- #done(clock_end: Util.monotonic_micros) ⇒ Object private
-
#initialize(name:, transaction:, trace_context:, parent:, type: nil, subtype: nil, action: nil, context: nil, stacktrace_builder: nil, sync: nil) ⇒ Span
constructor
private
rubocop:disable Metrics/ParameterLists.
- #inspect ⇒ Object private
- #prepare_for_serialization! ⇒ Object private
- #running? ⇒ Boolean private
- #set_destination(address: nil, port: nil, service: nil, cloud: nil) ⇒ Object private
-
#start(clock_start = Util.monotonic_micros) ⇒ Object
private
life cycle.
- #started? ⇒ Boolean private
- #stop(clock_end = Util.monotonic_micros) ⇒ Object private
- #stopped? ⇒ Boolean private
Methods included from ChildDurations::Methods
#child_durations, #child_started, #child_stopped
Constructor Details
#initialize(name:, transaction:, trace_context:, parent:, type: nil, subtype: nil, action: nil, context: nil, stacktrace_builder: nil, sync: nil) ⇒ Span
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/ParameterLists
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 |
# File 'lib/elastic_apm/span.rb', line 42 def initialize( name:, transaction:, trace_context:, parent:, type: nil, subtype: nil, action: nil, context: nil, stacktrace_builder: nil, sync: nil ) @name = name if subtype.nil? && type&.include?('.') @type, @subtype, @action = type.split('.') else @type = type || DEFAULT_TYPE @subtype = subtype @action = action end @transaction = transaction @parent = parent @trace_context = trace_context || parent.trace_context.child @sample_rate = transaction.sample_rate @context = context || Span::Context.new(sync: sync) @stacktrace_builder = stacktrace_builder end |
Instance Attribute Details
#action ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def action @action end |
#context ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def context @context end |
#duration ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def duration @duration end |
#name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def name @name end |
#original_backtrace ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def original_backtrace @original_backtrace end |
#outcome ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def outcome @outcome end |
#parent ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def parent @parent end |
#sample_rate ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def sample_rate @sample_rate end |
#self_time ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def self_time @self_time end |
#stacktrace ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def stacktrace @stacktrace end |
#subtype ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def subtype @subtype end |
#timestamp ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def @timestamp end |
#trace_context ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def trace_context @trace_context end |
#transaction ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/elastic_apm/span.rb', line 85 def transaction @transaction end |
#type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/elastic_apm/span.rb', line 76 def type @type end |
Instance Method Details
#done(clock_end: Util.monotonic_micros) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
112 113 114 115 |
# File 'lib/elastic_apm/span.rb', line 112 def done(clock_end: Util.monotonic_micros) stop clock_end self end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
143 144 145 146 147 148 |
# File 'lib/elastic_apm/span.rb', line 143 def inspect "<ElasticAPM::Span id:#{trace_context&.id}" \ " name:#{name.inspect}" \ " type:#{type.inspect}" \ '>' end |
#prepare_for_serialization! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 120 |
# File 'lib/elastic_apm/span.rb', line 117 def prepare_for_serialization! build_stacktrace! if should_build_stacktrace? self.original_backtrace = nil # release original end |
#running? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 |
# File 'lib/elastic_apm/span.rb', line 130 def running? started? && !stopped? end |
#set_destination(address: nil, port: nil, service: nil, cloud: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
134 135 136 137 138 139 140 141 |
# File 'lib/elastic_apm/span.rb', line 134 def set_destination(address: nil, port: nil, service: nil, cloud: nil) context.destination = Span::Context::Destination.new( address: address, port: port, service: service, cloud: cloud ) end |
#start(clock_start = Util.monotonic_micros) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
life cycle
98 99 100 101 102 103 |
# File 'lib/elastic_apm/span.rb', line 98 def start(clock_start = Util.monotonic_micros) @timestamp = Util.micros @clock_start = clock_start @parent.child_started self end |
#started? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
126 127 128 |
# File 'lib/elastic_apm/span.rb', line 126 def started? !! end |
#stop(clock_end = Util.monotonic_micros) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
105 106 107 108 109 110 |
# File 'lib/elastic_apm/span.rb', line 105 def stop(clock_end = Util.monotonic_micros) @duration ||= (clock_end - @clock_start) @parent.child_stopped @self_time = @duration - child_durations.duration self end |
#stopped? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 |
# File 'lib/elastic_apm/span.rb', line 122 def stopped? !!duration end |