Class: ElasticAPM::Transaction Private
- Inherits:
-
Object
- Object
- ElasticAPM::Transaction
- Extended by:
- Deprecations
- Defined in:
- lib/elastic_apm/transaction.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.
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
- #context ⇒ Object readonly private
- #dropped_spans ⇒ Object readonly private
- #duration ⇒ Object readonly private
-
#name ⇒ Object
private
rubocop:enable Metrics/ParameterLists, Metrics/MethodLength.
- #notifications ⇒ Object readonly private
- #parent_id ⇒ Object readonly private
-
#result ⇒ Object
private
rubocop:enable Metrics/ParameterLists, Metrics/MethodLength.
- #started_spans ⇒ Object readonly private
- #timestamp ⇒ Object readonly private
- #trace_context ⇒ Object readonly private
-
#type ⇒ Object
private
rubocop:enable Metrics/ParameterLists, Metrics/MethodLength.
Instance Method Summary collapse
-
#add_response(*args) ⇒ Object
private
context.
- #done(result = nil, end_time: Util.micros) ⇒ Object private
- #done? ⇒ Boolean private
- #ensure_parent_id ⇒ Object private
- #id ⇒ Object private
- #inc_dropped_spans! ⇒ Object private
-
#inc_started_spans! ⇒ Object
private
spans.
-
#initialize(name = nil, type = nil, sampled: true, context: nil, tags: nil, trace_context: nil) ⇒ Transaction
constructor
private
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
- #inspect ⇒ Object private
- #max_spans_reached?(config) ⇒ Boolean private
- #sampled? ⇒ Boolean private
-
#start(timestamp = Util.micros) ⇒ Object
private
life cycle.
- #stop(end_timestamp = Util.micros) ⇒ Object private
- #stopped? ⇒ Boolean private
- #trace_id ⇒ Object private
Methods included from Deprecations
Constructor Details
#initialize(name = nil, type = nil, sampled: true, context: nil, tags: nil, trace_context: nil) ⇒ Transaction
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, Metrics/MethodLength
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/elastic_apm/transaction.rb', line 13 def initialize( name = nil, type = nil, sampled: true, context: nil, tags: nil, trace_context: nil ) @name = name @type = type || DEFAULT_TYPE @sampled = sampled @context = context || Context.new # TODO: Lazy generate this? Util.reverse_merge!(@context., ) if if trace_context @parent_id = trace_context.span_id @trace_context = trace_context else @trace_context = TraceContext.for_transaction(sampled: sampled) end @started_spans = 0 @dropped_spans = 0 @notifications = [] # for AS::Notifications end |
Instance Attribute Details
#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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def context @context end |
#dropped_spans ⇒ 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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def dropped_spans @dropped_spans 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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 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.
rubocop:enable Metrics/ParameterLists, Metrics/MethodLength
43 44 45 |
# File 'lib/elastic_apm/transaction.rb', line 43 def name @name end |
#notifications ⇒ 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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def notifications @notifications end |
#parent_id ⇒ 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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def parent_id @parent_id end |
#result ⇒ 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.
rubocop:enable Metrics/ParameterLists, Metrics/MethodLength
43 44 45 |
# File 'lib/elastic_apm/transaction.rb', line 43 def result @result end |
#started_spans ⇒ 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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def started_spans @started_spans 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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def end |
#trace_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.
45 46 47 |
# File 'lib/elastic_apm/transaction.rb', line 45 def trace_context @trace_context 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.
rubocop:enable Metrics/ParameterLists, Metrics/MethodLength
43 44 45 |
# File 'lib/elastic_apm/transaction.rb', line 43 def type @type end |
Instance Method Details
#add_response(*args) ⇒ 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.
context
110 111 112 |
# File 'lib/elastic_apm/transaction.rb', line 110 def add_response(*args) context.response = Context::Response.new(*args) end |
#done(result = nil, end_time: Util.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.
83 84 85 86 87 |
# File 'lib/elastic_apm/transaction.rb', line 83 def done(result = nil, end_time: Util.micros) stop end_time self.result = result if result self end |
#done? ⇒ 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.
60 61 62 |
# File 'lib/elastic_apm/transaction.rb', line 60 def done? stopped? end |
#ensure_parent_id ⇒ 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.
89 90 91 92 |
# File 'lib/elastic_apm/transaction.rb', line 89 def ensure_parent_id @parent_id ||= SecureRandom.hex(8) @parent_id end |
#id ⇒ 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.
48 49 50 |
# File 'lib/elastic_apm/transaction.rb', line 48 def id trace_context.span_id end |
#inc_dropped_spans! ⇒ 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.
100 101 102 |
# File 'lib/elastic_apm/transaction.rb', line 100 def inc_dropped_spans! @dropped_spans += 1 end |
#inc_started_spans! ⇒ 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.
spans
96 97 98 |
# File 'lib/elastic_apm/transaction.rb', line 96 def inc_started_spans! @started_spans += 1 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.
114 115 116 117 |
# File 'lib/elastic_apm/transaction.rb', line 114 def inspect "<ElasticAPM::Transaction id:#{id}" \ " name:#{name.inspect} type:#{type.inspect}>" end |
#max_spans_reached?(config) ⇒ 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.
104 105 106 |
# File 'lib/elastic_apm/transaction.rb', line 104 def max_spans_reached?(config) started_spans > config.transaction_max_spans end |
#sampled? ⇒ 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.
52 53 54 |
# File 'lib/elastic_apm/transaction.rb', line 52 def sampled? @sampled end |
#start(timestamp = Util.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
72 73 74 75 |
# File 'lib/elastic_apm/transaction.rb', line 72 def start( = Util.micros) = self end |
#stop(end_timestamp = Util.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.
77 78 79 80 81 |
# File 'lib/elastic_apm/transaction.rb', line 77 def stop( = Util.micros) raise 'Transaction not yet start' unless @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.
56 57 58 |
# File 'lib/elastic_apm/transaction.rb', line 56 def stopped? !!duration end |
#trace_id ⇒ 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.
66 67 68 |
# File 'lib/elastic_apm/transaction.rb', line 66 def trace_id trace_context&.trace_id end |