class StackifyRubyAPM::Transaction
@api private
Constants
- DEFAULT_TYPE
Attributes
context[R]
dropped_spans[R]
duration[R]
exceptions[R]
http_status[RW]
id[R]
instrumenter[R]
name[RW]
notifications[R]
result[R]
spans[R]
timestamp[R]
type[RW]
Public Class Methods
new(instrumenter, name = nil, type = nil, context: nil) { |self| ... }
click to toggle source
# 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
Public Instance Methods
add_exception(exception)
click to toggle source
# File lib/stackify_apm/transaction.rb, line 37 def add_exception(exception) @exceptions << exception end
current_span()
click to toggle source
# File lib/stackify_apm/transaction.rb, line 85 def current_span spans.reverse.lazy.find(&:running?) end
done(result = nil)
click to toggle source
# 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?()
click to toggle source
# File lib/stackify_apm/transaction.rb, line 53 def done? !@duration.nil? end
inspect()
click to toggle source
# File lib/stackify_apm/transaction.rb, line 89 def inspect "<StackifyRubyAPM::Transaction id:#{id}" \ " name:#{name.inspect}" \ " type:#{type.inspect}" \ '>' end
release()
click to toggle source
# File lib/stackify_apm/transaction.rb, line 41 def release @instrumenter.current_transaction = nil end
running_spans()
click to toggle source
This method is being used in unit testing
# File lib/stackify_apm/transaction.rb, line 68 def running_spans spans.select(&:running?) end
span(name, type = nil, backtrace: nil, context: nil) { |span| ... }
click to toggle source
# 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: {})
click to toggle source
# 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
Private Instance Methods
build_and_start_span(name, type, context, backtrace)
click to toggle source
# File lib/stackify_apm/transaction.rb, line 118 def build_and_start_span(name, type, context, backtrace) span = Span.new( self, next_span_id, name, type, parent_id: current_span.nil? ? -1 : current_span.id, context: context, http_status: @http_status ) # span = next_span(name, type, context) spans << span span.original_backtrace = backtrace if backtrace && span_frames_min_duration? span.start end
next_span(name, type, context)
click to toggle source
# File lib/stackify_apm/transaction.rb, line 102 def next_span(name, type, context) Span.new( self, next_span_id, name, type, parent_id: current_span.nil? ? -1 : current_span.id, context: context, http_status: @http_status ) end
next_span_id()
click to toggle source
# File lib/stackify_apm/transaction.rb, line 98 def next_span_id @span_id_ticker += 1 end
span_frames_min_duration?()
click to toggle source
# File lib/stackify_apm/transaction.rb, line 114 def span_frames_min_duration? @instrumenter.agent.config.span_frames_min_duration != 0 end