private void HandleRequestStop()

in src/ServiceProfiler.EventPipe.Otel/Azure.Monitor.OpenTelemetry.Profiler.Core/EventListeners/TraceSessionListener.cs [204:236]


    private void HandleRequestStop(EventWrittenEventArgs eventData, string requestName, string requestId, string operationId, string id)
    {
        bool isDebugLoggingEnabled = _logger.IsEnabled(LogLevel.Debug);
        if (isDebugLoggingEnabled)
        {
            _logger.LogDebug("Request stopped: Activity Id: {activityId}", eventData.ActivityId);
        }

        if (!_startedActivityIds.TryRemove(id, out _))
        {
            if (isDebugLoggingEnabled)
            {
                _logger.LogDebug("No start activity found for this stop activity. Request name: {requestName}, id: {id}", requestName, id);
            }

            // No interesting start activity captured, it then doesn't make sense to just capture the stop.
            return;
        }

        if (isDebugLoggingEnabled)
        {
            _logger.LogDebug("Interesting activity found. Name: {name}, id: {id}", requestName, id);
        }
        // Interesting start activity was captured, relay this stop activity.
        AzureMonitorOpenTelemetryProfilerDataAdapterEventSource.Log.RequestStop(
            name: requestName, id: id, requestId: requestId, operationId: operationId);

        if (!_hasActivityReported && _logger.IsEnabled(LogLevel.Information))
        {
            _logger.LogInformation("Activity detected.");
            _hasActivityReported = true;
        }
    }