class ElasticAPM::Instrumenter

def start_transaction(

rubocop:disable Metrics/MethodLength
def start_transaction(
  name = nil,
  type = nil,
  config:,
  context: nil,
  trace_context: nil
)
  return nil unless config.instrument?
  if (transaction = current_transaction)
    raise ExistingTransactionError,
      "Transactions may not be nested.\n" \
      "Already inside #{transaction.inspect}"
  end
  sampled = trace_context ? trace_context.recorded? : random_sample?(config)
  transaction =
    Transaction.new(
      name,
      type,
      context: context,
      trace_context: trace_context,
      sampled: sampled,
      config: config
    )
  transaction.start
  self.current_transaction = transaction
end