def start_span(
      name,
      type = nil,
      backtrace: nil,
      context: nil,
      trace_context: nil
    )
      return unless (transaction = current_transaction)
      return unless transaction.sampled?

      transaction.inc_started_spans!

      if transaction.max_spans_reached?(config)
        transaction.inc_dropped_spans!
        return
      end

      parent = current_span || transaction

      span = Span.new(
        name: name,
        transaction_id: transaction.id,
        trace_context: trace_context || parent.trace_context.child,
        type: type,
        context: context,
        stacktrace_builder: stacktrace_builder
      )

      if backtrace && config.span_frames_min_duration?
        span.original_backtrace = backtrace
      end

      current_spans.push span

      span.start
    end
def start_span(
      name,
      type = nil,
      backtrace: nil,
      context: nil,
      trace_context: nil
    )
      return unless (transaction = current_transaction)
      return unless transaction.sampled?

      transaction.inc_started_spans!

      if transaction.max_spans_reached?(config)
        transaction.inc_dropped_spans!
        return
      end

      parent = current_span || transaction

      span = Span.new(
        name: name,
        transaction_id: transaction.id,
        trace_context: trace_context || parent.trace_context.child,
        type: type,
        context: context,
        stacktrace_builder: stacktrace_builder
      )

      if backtrace && config.span_frames_min_duration?
        span.original_backtrace = backtrace
      end

      current_spans.push span

      span.start
    end
rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
 rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity