Class: ElasticAPM::Transaction Private
- Inherits:
-
Object
- Object
- ElasticAPM::Transaction
- Extended by:
- Forwardable
- Includes:
- ChildDurations::Methods
- 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.
Defined Under Namespace
Classes: Outcome
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'
- MUTEX =
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.
Mutex.new
Instance Attribute Summary collapse
- #breakdown_metrics ⇒ Object readonly private
- #collect_metrics ⇒ Object (also: #collect_metrics?) readonly private
- #context ⇒ Object readonly private
- #dropped_spans ⇒ Object readonly private
- #duration ⇒ Object readonly private
- #framework_name ⇒ Object readonly private
-
#name ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
- #notifications ⇒ Object readonly private
-
#outcome ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
-
#result ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
- #sample_rate ⇒ Object readonly private
- #self_time ⇒ Object readonly private
- #span_frames_min_duration ⇒ Object readonly private
- #started_spans ⇒ Object readonly private
- #timestamp ⇒ Object readonly private
- #trace_context ⇒ Object readonly private
- #transaction_max_spans ⇒ Object readonly private
-
#type ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
Instance Method Summary collapse
-
#add_response(status = nil, **args) ⇒ Object
private
context.
- #done(result = nil, clock_end: Util.monotonic_micros) ⇒ Object private
-
#inc_started_spans! ⇒ Object
private
spans.
-
#initialize(name = nil, type = nil, config:, sampled: true, sample_rate: 1, context: nil, trace_context: nil) ⇒ Transaction
constructor
private
rubocop:disable Metrics/ParameterLists.
- #inspect ⇒ Object private
- #sampled? ⇒ Boolean private
- #set_user(user) ⇒ Object private
-
#start(clock_start = Util.monotonic_micros) ⇒ Object
private
life cycle.
- #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 = nil, type = nil, config:, sampled: true, sample_rate: 1, context: 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
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 86 87 |
# File 'lib/elastic_apm/transaction.rb', line 44 def initialize( name = nil, type = nil, config:, sampled: true, sample_rate: 1, context: nil, trace_context: nil ) @name = name @type = type || DEFAULT_TYPE @config = config # Cache these values in case they are changed during the # transaction's lifetime via the remote config @span_frames_min_duration = config.span_frames_min_duration @collect_metrics = config.collect_metrics? @breakdown_metrics = config.breakdown_metrics? @framework_name = config.framework_name @transaction_max_spans = config.transaction_max_spans @default_labels = config.default_labels @sampled = sampled @sample_rate = sample_rate @context = context || Context.new # TODO: Lazy generate this? if @default_labels Util.reverse_merge!(@context.labels, @default_labels) end unless (@trace_context = trace_context) @trace_context = TraceContext.new( traceparent: TraceContext::Traceparent.new(recorded: sampled), tracestate: TraceContext::Tracestate.new( sample_rate: sampled ? sample_rate : 0 ) ) end @started_spans = 0 @dropped_spans = 0 @notifications = [] # for AS::Notifications end |
Instance Attribute Details
#breakdown_metrics ⇒ 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def breakdown_metrics @breakdown_metrics end |
#collect_metrics ⇒ Object (readonly) Also known as: collect_metrics?
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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def collect_metrics @collect_metrics 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def duration @duration end |
#framework_name ⇒ 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def framework_name @framework_name 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
90 91 92 |
# File 'lib/elastic_apm/transaction.rb', line 90 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def notifications @notifications 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.
rubocop:enable Metrics/ParameterLists
90 91 92 |
# File 'lib/elastic_apm/transaction.rb', line 90 def outcome @outcome 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
90 91 92 |
# File 'lib/elastic_apm/transaction.rb', line 90 def result @result 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def self_time @self_time end |
#span_frames_min_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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def span_frames_min_duration @span_frames_min_duration 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def @timestamp 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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def trace_context @trace_context end |
#transaction_max_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.
92 93 94 |
# File 'lib/elastic_apm/transaction.rb', line 92 def transaction_max_spans @transaction_max_spans 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
90 91 92 |
# File 'lib/elastic_apm/transaction.rb', line 90 def type @type end |
Instance Method Details
#add_response(status = nil, **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
156 157 158 |
# File 'lib/elastic_apm/transaction.rb', line 156 def add_response(status = nil, **args) context.response = Context::Response.new(status, **args) end |
#done(result = nil, 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.
135 136 137 138 139 |
# File 'lib/elastic_apm/transaction.rb', line 135 def done(result = nil, clock_end: Util.monotonic_micros) stop clock_end self.result = result if result self 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
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/elastic_apm/transaction.rb', line 143 def inc_started_spans! MUTEX.synchronize do @started_spans += 1 if @started_spans > transaction_max_spans @dropped_spans += 1 return false end end true 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.
164 165 166 167 |
# File 'lib/elastic_apm/transaction.rb', line 164 def inspect "<ElasticAPM::Transaction id:#{id}" \ " name:#{name.inspect} type:#{type.inspect}>" 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.
111 112 113 |
# File 'lib/elastic_apm/transaction.rb', line 111 def sampled? @sampled end |
#set_user(user) ⇒ 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.
160 161 162 |
# File 'lib/elastic_apm/transaction.rb', line 160 def set_user(user) context.user = Context::User.infer(@config, user) 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
121 122 123 124 125 |
# File 'lib/elastic_apm/transaction.rb', line 121 def start(clock_start = Util.monotonic_micros) @timestamp = Util.micros @clock_start = clock_start self 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.
127 128 129 130 131 132 133 |
# File 'lib/elastic_apm/transaction.rb', line 127 def stop(clock_end = Util.monotonic_micros) raise 'Transaction not yet start' unless @duration = clock_end - @clock_start @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.
115 116 117 |
# File 'lib/elastic_apm/transaction.rb', line 115 def stopped? !!duration end |