public static void StopInternalActivity()

in src/OpenTelemetryEngine/Traces/FunctionsActivityBuilder.cs [50:68]


        public static void StopInternalActivity(string invocationId)
        {
            if (internalActivitiesByInvocationId.Keys.Contains(invocationId)) 
            {
                if (internalActivitiesByInvocationId.TryRemove(invocationId, out Activity? activityToStop))
                {
                    activityToStop.Stop();
                }
                else 
                {
                    // There are two reasons why the activity may not be removed from the dictionary:
                    // 1. The activity was added successfully to the dictionary but was already removed from the dictionary by another thread
                    //    Due to the architecture of Azure Functions, this is not likely unless the user calls these cmdlets manually
                    //    If this happens, the activity was already stopped and the user should not be concerned
                    // 2. The activity was not added successfully to the dictionary
                    //    This is also not a concern - this only happens if the key already exists and we guard this case in StartInternalActivity
                }
            }
        }