internal StreamingMessage ProcessFunctionEnvironmentReloadRequest()

in src/RequestProcessor.cs [379:411]


        internal StreamingMessage ProcessFunctionEnvironmentReloadRequest(StreamingMessage request)
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            var environmentReloadRequest = request.FunctionEnvironmentReloadRequest;

            var rpcLogger = new RpcLogger(_msgStream);
            rpcLogger.SetContext(request.RequestId, null);

            var functionsEnvironmentReloader = new FunctionsEnvironmentReloader(rpcLogger);
            functionsEnvironmentReloader.ReloadEnvironment(
                environmentReloadRequest.EnvironmentVariables,
                environmentReloadRequest.FunctionAppDirectory);

            rpcLogger.Log(isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.EnvironmentReloadCompleted, stopwatch.ElapsedMilliseconds));

            StreamingMessage response = NewStreamingMessageTemplate(
                request.RequestId,
                StreamingMessage.ContentOneofCase.FunctionEnvironmentReloadResponse,
                out StatusResult status);

            // This will force the OpenTelemetryController to check the environment variables and module presence again
            OpenTelemetryController.ResetOpenTelemetryModuleStatus();
            if (OpenTelemetryController.IsOpenTelemetryEnvironmentEnabled())
            {
                // Note: The ability to edit worker capabilities is new within the last few months. I am unsure if we need to 
                // report all prior capabilities that were sent at worker init. Going with minimal change for now. 
                response.FunctionEnvironmentReloadResponse.Capabilities.Add("WorkerOpenTelemetryEnabled", "true");
            }

            return response;
        }