function shouldGenerateSpanEvents(config, txn) {
  if (!(config.distributed_tracing.enabled && config.span_events.enabled)) {
    return false
  }

  const infiniteTracingConfigured = Boolean(config.infinite_tracing.trace_observer.host)
  return infiniteTracingConfigured || txn.sampled
}
Iterates over the trace tree and generates a span event for each segment.
@param {Node} [node] the node to process the segment and its children