Class: Atatus::Transaction Private
- Inherits:
-
Object
- Object
- Atatus::Transaction
- Extended by:
- Forwardable
- Includes:
- ChildDurations::Methods
- Defined in:
- lib/atatus/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'
- 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
-
#result ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
-
#ruby_time ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
- #sample_rate ⇒ Object readonly private
- #self_time ⇒ Object readonly private
- #span_frames_min_duration ⇒ Object readonly private
-
#spans ⇒ Object
private
rubocop:enable Metrics/ParameterLists.
- #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, sampled: true, sample_rate: 1, context: nil, config:, trace_context: nil) ⇒ Transaction
constructor
private
rubocop:disable Metrics/ParameterLists.
- #inspect ⇒ Object private
- #sampled? ⇒ Boolean private
- #set_company(company) ⇒ Object private
- #set_response_body(response_body) ⇒ Object 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, sampled: true, sample_rate: 1, context: nil, config:, 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
33 34 35 36 37 38 39 40 41 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 72 73 74 |
# File 'lib/atatus/transaction.rb', line 33 def initialize( name = nil, type = nil, sampled: true, sample_rate: 1, context: nil, config:, 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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
77 78 79 |
# File 'lib/atatus/transaction.rb', line 77 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 def notifications @notifications 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
77 78 79 |
# File 'lib/atatus/transaction.rb', line 77 def result @result end |
#ruby_time ⇒ 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
77 78 79 |
# File 'lib/atatus/transaction.rb', line 77 def ruby_time @ruby_time 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 def span_frames_min_duration @span_frames_min_duration end |
#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.
rubocop:enable Metrics/ParameterLists
77 78 79 |
# File 'lib/atatus/transaction.rb', line 77 def spans @spans 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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.
79 80 81 |
# File 'lib/atatus/transaction.rb', line 79 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
77 78 79 |
# File 'lib/atatus/transaction.rb', line 77 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
143 144 145 |
# File 'lib/atatus/transaction.rb', line 143 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.
122 123 124 125 126 |
# File 'lib/atatus/transaction.rb', line 122 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
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/atatus/transaction.rb', line 130 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.
159 160 161 162 |
# File 'lib/atatus/transaction.rb', line 159 def inspect "<Atatus::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.
98 99 100 |
# File 'lib/atatus/transaction.rb', line 98 def sampled? @sampled end |
#set_company(company) ⇒ 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.
151 152 153 |
# File 'lib/atatus/transaction.rb', line 151 def set_company(company) context.company = Context::Company.infer(@config, company) end |
#set_response_body(response_body) ⇒ 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.
155 156 157 |
# File 'lib/atatus/transaction.rb', line 155 def set_response_body(response_body) context.response_body = response_body 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.
147 148 149 |
# File 'lib/atatus/transaction.rb', line 147 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
108 109 110 111 112 |
# File 'lib/atatus/transaction.rb', line 108 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.
114 115 116 117 118 119 120 |
# File 'lib/atatus/transaction.rb', line 114 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.
102 103 104 |
# File 'lib/atatus/transaction.rb', line 102 def stopped? !!duration end |