Class: StackifyRubyAPM::Transaction Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::Transaction
- Defined in:
- lib/stackify_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'.freeze
Instance Attribute Summary collapse
- #context ⇒ Object readonly private
- #dropped_spans ⇒ Object readonly private
- #duration ⇒ Object readonly private
- #exceptions ⇒ Object readonly private
- #http_status ⇒ Object private
- #id ⇒ Object readonly private
- #instrumenter ⇒ Object readonly private
- #name ⇒ Object private
- #notifications ⇒ Object readonly private
- #result ⇒ Object readonly private
- #spans ⇒ Object readonly private
- #timestamp ⇒ Object readonly private
- #type ⇒ Object private
Instance Method Summary collapse
- #add_exception(exception) ⇒ Object private
- #current_span ⇒ Object private
- #done(result = nil) ⇒ Object private
- #done? ⇒ Boolean private
-
#initialize(instrumenter, name = nil, type = nil, context: nil) {|_self| ... } ⇒ Transaction
constructor
private
A new instance of Transaction.
- #inspect ⇒ Object private
- #release ⇒ Object private
-
#running_spans ⇒ Object
private
This method is being used in unit testing.
- #span(name, type = nil, backtrace: nil, context: nil) ⇒ Object private
- #submit(result = nil, status: nil, headers: {}) ⇒ Object private
Constructor Details
#initialize(instrumenter, name = nil, type = nil, context: nil) {|_self| ... } ⇒ 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.
Returns a new instance of Transaction.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stackify_apm/transaction.rb', line 12 def initialize(instrumenter, name = nil, type = nil, context: nil) # puts "Loads transaction new initialize # instrumenter, name = nil, type = nil, context: nil" @id = SecureRandom.uuid @instrumenter = instrumenter @name = name @type = type || DEFAULT_TYPE @timestamp = Time.now.to_f * 1000 @spans = [] @span_id_ticker = -1 @dropped_spans = 0 @notifications = [] # for AS::Notifications @context = context || Context.new @exceptions = [] yield self if block_given? 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.
34 35 36 |
# File 'lib/stackify_apm/transaction.rb', line 34 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.
34 35 36 |
# File 'lib/stackify_apm/transaction.rb', line 34 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.
34 35 36 |
# File 'lib/stackify_apm/transaction.rb', line 34 def duration @duration end |
#exceptions ⇒ 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.
35 36 37 |
# File 'lib/stackify_apm/transaction.rb', line 35 def exceptions @exceptions end |
#http_status ⇒ 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.
33 34 35 |
# File 'lib/stackify_apm/transaction.rb', line 33 def http_status @http_status end |
#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.
34 35 36 |
# File 'lib/stackify_apm/transaction.rb', line 34 def id @id end |
#instrumenter ⇒ 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.
34 35 36 |
# File 'lib/stackify_apm/transaction.rb', line 34 def instrumenter @instrumenter 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.
33 34 35 |
# File 'lib/stackify_apm/transaction.rb', line 33 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.
35 36 37 |
# File 'lib/stackify_apm/transaction.rb', line 35 def notifications @notifications end |
#result ⇒ 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.
35 36 37 |
# File 'lib/stackify_apm/transaction.rb', line 35 def result @result end |
#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.
35 36 37 |
# File 'lib/stackify_apm/transaction.rb', line 35 def spans @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.
35 36 37 |
# File 'lib/stackify_apm/transaction.rb', line 35 def @timestamp 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.
33 34 35 |
# File 'lib/stackify_apm/transaction.rb', line 33 def type @type end |
Instance Method Details
#add_exception(exception) ⇒ 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.
37 38 39 |
# File 'lib/stackify_apm/transaction.rb', line 37 def add_exception(exception) @exceptions << exception end |
#current_span ⇒ 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.
85 86 87 |
# File 'lib/stackify_apm/transaction.rb', line 85 def current_span spans.reverse.lazy.find(&:running?) end |
#done(result = 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.
45 46 47 48 49 50 51 |
# File 'lib/stackify_apm/transaction.rb', line 45 def done(result = nil) @duration = Time.now.to_f * 1000 @result = result @http_status = 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.
53 54 55 |
# File 'lib/stackify_apm/transaction.rb', line 53 def done? !@duration.nil? 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.
89 90 91 92 93 94 |
# File 'lib/stackify_apm/transaction.rb', line 89 def inspect "<StackifyRubyAPM::Transaction id:#{id}" \ " name:#{name.inspect}" \ " type:#{type.inspect}" \ '>' end |
#release ⇒ 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.
41 42 43 |
# File 'lib/stackify_apm/transaction.rb', line 41 def release @instrumenter.current_transaction = nil end |
#running_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.
This method is being used in unit testing
68 69 70 |
# File 'lib/stackify_apm/transaction.rb', line 68 def running_spans spans.select(&:running?) end |
#span(name, type = nil, backtrace: nil, context: 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.
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/stackify_apm/transaction.rb', line 72 def span(name, type = nil, backtrace: nil, context: nil) span = build_and_start_span(name, type, context, backtrace) return span unless block_given? begin result = yield span ensure span.done end result end |
#submit(result = nil, status: nil, headers: {}) ⇒ 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.
57 58 59 60 61 62 63 64 65 |
# File 'lib/stackify_apm/transaction.rb', line 57 def submit(result = nil, status: nil, headers: {}) done result unless duration context.response = Context::Response.new(status, headers: headers) if status release @instrumenter.submit_transaction self self end |