private void GenerateAndCollectSpanEvents(ImmutableTransaction immutableTransaction, string transactionName, Func <IAttributeValueCollection> attributes)
        {
            var useInfiniteTracing    = _spanEventAggregatorInfiniteTracing.IsServiceEnabled && _spanEventAggregatorInfiniteTracing.IsServiceAvailable;
            var useTraditionalTracing = !useInfiniteTracing && immutableTransaction.Sampled && _spanEventAggregator.IsServiceEnabled && _spanEventAggregator.IsServiceAvailable;

            if (!useInfiniteTracing && !useTraditionalTracing)
            {
                return;
            }

            var countProposedSpans = immutableTransaction.Segments.Count + 1;

            if (useInfiniteTracing && !_spanEventAggregatorInfiniteTracing.HasCapacity(countProposedSpans))
            {
                _spanEventAggregatorInfiniteTracing.RecordSeenSpans(countProposedSpans);
                _spanEventAggregatorInfiniteTracing.RecordDroppedSpans(countProposedSpans);
                return;
            }

            var spanEvents = _spanEventMaker.GetSpanEvents(immutableTransaction, transactionName, attributes.Invoke());

            using (_agentTimerService.StartNew("CollectSpanEvents"))
            {
                if (useInfiniteTracing)
                {
                    _spanEventAggregatorInfiniteTracing.Collect(spanEvents);
                }
                else
                {
                    _spanEventAggregator.Collect(spanEvents);
                }
            }
        }