class ElasticAPM::Transaction

@api private

def add_response(*args)

def add_response(*args)
  context.response = Context::Response.new(*args)
end

def done(result = nil, end_time: Util.micros)

def done(result = nil, end_time: Util.micros)
  stop end_time
  self.result = result if result
  self
end

def done?

def done?
  stopped?
end

def inc_dropped_spans!

def inc_dropped_spans!
  @dropped_spans += 1
end

def inc_started_spans!

def inc_started_spans!
  @started_spans += 1
end

def initialize(

rubocop:disable Metrics/ParameterLists
def initialize(
  name = nil,
  type = nil,
  sampled: true,
  context: nil,
  tags: nil,
  trace_context: nil
)
  @name = name
  @type = type || DEFAULT_TYPE
  @sampled = sampled
  @context = context || Context.new # TODO: Lazy generate this?
  Util.reverse_merge!(@context.tags, tags) if tags
  @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 max_spans_reached?(config)

def max_spans_reached?(config)
  started_spans > config.transaction_max_spans
end

def sampled?

def sampled?
  @sampled
end

def start(timestamp = Util.micros)

def start(timestamp = Util.micros)
  @timestamp = timestamp
  self
end

def stop(end_timestamp = Util.micros)

def stop(end_timestamp = Util.micros)
  raise 'Transaction not yet start' unless timestamp
  @duration = end_timestamp - timestamp
  self
end

def stopped?

def stopped?
  !!duration
end