コード例 #1
0
        private string StartThreadProfilingSessions(IDictionary <string, object> arguments)
        {
            if (arguments == null)
            {
                return("No arguments sent with start_profiler command.");
            }

            if (!AgentInstallConfiguration.IsWindows && !AgentInstallConfiguration.IsNetCore30OrAbove)
            {
                const string netCore30RequiredForLinuxThreadProfiling = "Cannot start a thread profiling session. Thread profiling support on Linux was introduced in .NET Core 3.0.";
                Log.Info(netCore30RequiredForLinuxThreadProfiling);
                return(netCore30RequiredForLinuxThreadProfiling);
            }

            var startArgs = new ThreadProfilerCommandArgs(arguments);

            if (startArgs.ProfileId == 0)
            {
                return("A valid profile_id must be supplied to start a thread profiling session.");
            }

            var startedNewSession = ThreadProfilingService.StartThreadProfilingSession(startArgs.ProfileId, startArgs.Frequency, startArgs.Duration);

            if (!startedNewSession)
            {
                return("Cannot start a thread profiling session. Another session may already be in process.");
            }

            return(null);
        }
コード例 #2
0
        private string StopThreadProfilingSessions(IDictionary <string, object> arguments)
        {
            if (arguments == null)
            {
                return("No arguments sent with stop_profiler command.");
            }

            var stopArgs = new ThreadProfilerCommandArgs(arguments);

            if (stopArgs.ProfileId == 0)
            {
                return("A valid profile_id must be supplied to stop a thread profiling session.");
            }

            try
            {
                var stoppedSession = ThreadProfilingService.StopThreadProfilingSession(stopArgs.ProfileId, stopArgs.ReportData);
                if (!stoppedSession)
                {
                    return("A thread profiling session is not running.");
                }
            }
            catch (InvalidProfileIdException e)
            {
                Log.Error(e.Message);
                return(e.Message);
            }

            return(null);
        }