class ElasticAPM::Span
@api private
def build_stacktrace!
def build_stacktrace! @stacktrace = @stacktrace_builder.build(original_backtrace, type: :span) self.original_backtrace = nil # release original end
def done(end_time: Util.micros)
def done(end_time: Util.micros) stop end_time build_stacktrace! if should_build_stacktrace? self end
def initialize(
def initialize( name:, transaction_id:, trace_context:, type: nil, context: nil, stacktrace_builder: nil ) @name = name @type = type || DEFAULT_TYPE @transaction_id = transaction_id @trace_context = trace_context @context = context || Span::Context.new @stacktrace_builder = stacktrace_builder end
def inspect
def inspect "<ElasticAPM::Span id:#{id}" \ " name:#{name.inspect}" \ " type:#{type.inspect}" \ '>' end
def long_enough_for_stacktrace?
def long_enough_for_stacktrace? min_duration = @stacktrace_builder.config.span_frames_min_duration_us return true if min_duration < 0 return false if min_duration == 0 duration >= min_duration end
def running?
def running? started? && !stopped? end
def should_build_stacktrace?
def should_build_stacktrace? @stacktrace_builder && original_backtrace && long_enough_for_stacktrace? end
def start(timestamp = Util.micros)
def start(timestamp = Util.micros) @timestamp = timestamp self end
def started?
def started? !!timestamp end
def stop(end_timestamp = Util.micros)
def stop(end_timestamp = Util.micros) @duration ||= (end_timestamp - timestamp) end
def stopped?
def stopped? !!duration end