class ElasticAPM::Transaction
@api private
def add_response(status = nil, **args)
def add_response(status = nil, **args) context.response = Context::Response.new(status, **args) end
def done(result = nil, clock_end: Util.monotonic_micros)
def done(result = nil, clock_end: Util.monotonic_micros) stop clock_end self.result = result if result self end
def inc_started_spans!
def inc_started_spans! MUTEX.synchronize do @started_spans += 1 if @started_spans > config.transaction_max_spans @dropped_spans += 1 return false end end true end
def initialize(
def initialize( name = nil, type = nil, sampled: true, context: nil, config:, trace_context: nil ) @name = name @type = type || DEFAULT_TYPE @config = config @sampled = sampled @context = context || Context.new # TODO: Lazy generate this? if config.default_labels Util.reverse_merge!(@context.labels, config.default_labels) end @trace_context = trace_context || TraceContext.new(recorded: sampled) @started_spans = 0 @dropped_spans = 0 @notifications = [] # for AS::Notifications end
def inspect
def inspect "<ElasticAPM::Transaction id:#{id}" \ " name:#{name.inspect} type:#{type.inspect}>" end
def sampled?
def sampled? @sampled end
def set_user(user)
def set_user(user) context.user = Context::User.infer(config, user) end
def start(clock_start = Util.monotonic_micros)
def start(clock_start = Util.monotonic_micros) @timestamp = Util.micros @clock_start = clock_start self end
def stop(clock_end = Util.monotonic_micros)
def stop(clock_end = Util.monotonic_micros) raise 'Transaction not yet start' unless timestamp @duration = clock_end - @clock_start @self_time = @duration - child_durations.duration self end
def stopped?
def stopped? !!duration end