コード例 #1
0
ファイル: Heartbeat.cs プロジェクト: seannguyen/Dynamo
        private void ExecThread()
        {
            Thread.Sleep(WARMUP_DELAY_MS);

            while (true)
            {
                try
                {
                    InstrumentationLogger.LogInfo("Heartbeat-Uptime-s",
                                                  DateTime.Now.Subtract(startTime)
                                                  .TotalSeconds.ToString(CultureInfo.InvariantCulture));

                    String usage  = PackFrequencyDict(ComputeNodeFrequencies());
                    String errors = PackFrequencyDict(ComputeErrorFrequencies());


                    InstrumentationLogger.LogInfo("Node-usage", usage);
                    InstrumentationLogger.LogInfo("Nodes-with-errors", errors);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Exception in Heartbeat " + e);
                }
                Thread.Sleep(HEARTBEAT_INTERVAL_MS);
            }
        }
コード例 #2
0
        private void ExecThread()
        {
            Thread.Sleep(WARMUP_DELAY_MS);

            while (true)
            {
                InstrumentationLogger.LogInfo("Heartbeat-Uptime-s", DateTime.Now.Subtract(startTime).TotalSeconds.ToString(CultureInfo.InvariantCulture));
                Thread.Sleep(HEARTBEAT_INTERVAL_MS);
            }
        }
コード例 #3
0
        private void ExecThread()
        {
            Thread.Sleep(WARMUP_DELAY_MS);

            while (true)
            {
                try
                {
                    StabilityCookie.WriteUptimeBeat(DateTime.Now.Subtract(startTime));

                    //Disable heartbeat to avoid 150 event/session limit
                    //InstrumentationLogger.LogAnonymousEvent("Heartbeat", "ApplicationLifeCycle", GetVersionString());

                    String usage  = PackFrequencyDict(ComputeNodeFrequencies());
                    String errors = PackFrequencyDict(ComputeErrorFrequencies());

                    InstrumentationLogger.LogPiiInfo("Node-usage", usage);
                    InstrumentationLogger.LogPiiInfo("Nodes-with-errors", errors);

                    dynamoModel.OnRequestDispatcherInvoke(
                        () =>
                    {
                        string workspace =
                            dynamoModel.CurrentWorkspace
                            .GetStringRepOfWorkspace();
                        InstrumentationLogger.LogPiiInfo("Workspace", workspace);
                    });
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Exception in Heartbeat " + e);
                }

                // The following call will return "true" if the event is
                // signaled, which can only happen when "DestroyInternal"
                // is called as the application is shutting down. Otherwise,
                // when the wait time ellapsed, the loop continues to log
                // the next set of information.
                //
                if (shutdownEvent.WaitOne(HEARTBEAT_INTERVAL_MS))
                {
                    break;
                }
            }
        }
コード例 #4
0
        private void ExecThread()
        {
            Thread.Sleep(WARMUP_DELAY_MS);

            while (true)
            {
                try
                {
                    InstrumentationLogger.LogInfo("VersionInfo", GetVersionString());

                    var difference = DateTime.Now.Subtract(startTime).TotalSeconds;
                    InstrumentationLogger.FORCE_LogInfo("Heartbeat-Uptime-s",
                                                        difference.ToString(CultureInfo.InvariantCulture));

                    String usage  = PackFrequencyDict(ComputeNodeFrequencies());
                    String errors = PackFrequencyDict(ComputeErrorFrequencies());


                    InstrumentationLogger.LogInfo("Node-usage", usage);
                    InstrumentationLogger.LogInfo("Nodes-with-errors", errors);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Exception in Heartbeat " + e);
                }

                // The following call will return "true" if the event is
                // signaled, which can only happen when "DestroyInternal"
                // is called as the application is shutting down. Otherwise,
                // when the wait time ellapsed, the loop continues to log
                // the next set of information.
                //
                if (shutdownEvent.WaitOne(HEARTBEAT_INTERVAL_MS))
                {
                    break;
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Notify the stability tracker that a crash has occured
 /// </summary>
 public void NotifyCrash()
 {
     InstrumentationLogger.LogAnonymousTimedEvent(
         "Stability", "TimeBetweenFailure", timeSinceLastCrash.Elapsed);
     timeSinceLastCrash.Restart();
 }
コード例 #6
0
        /// <summary>
        /// Start up and report the status of the last shutdown
        /// </summary>
        public static void Startup()
        {
            StabilityUtils.IsLastShutdownClean = IsLastShutdownClean();
            String cleanShutdownValue = Registry.GetValue(REG_KEY, SHUTDOWN_TYPE_NAME, null) as String;
            String uptimeValue        = Registry.GetValue(REG_KEY, UPTIME_NAME, null) as String;

            bool     isUptimeSpanValid = false;
            TimeSpan uptimeSpan        = TimeSpan.MinValue;


            long uptimeMs;

            if (long.TryParse(uptimeValue, out uptimeMs))
            {
                uptimeSpan        = TimeSpan.FromMilliseconds(uptimeMs);
                isUptimeSpanValid = true;
            }

            if (cleanShutdownValue == null || uptimeValue == null)
            {
                InstrumentationLogger.LogAnonymousEvent("FirstTimeStartup", "Stability");
            }
            else
            {
                switch (cleanShutdownValue)
                {
                case CLEAN_SHUTDOWN_VALUE:
                    InstrumentationLogger.LogAnonymousEvent("Clean shutdown", "Stability");
                    if (isUptimeSpanValid)
                    {
                        InstrumentationLogger.LogAnonymousTimedEvent("Stability", "Clean Uptime", uptimeSpan);
                    }
                    break;

                case CRASHING_SHUTDOWN_VALUE:
                    InstrumentationLogger.LogAnonymousEvent("Crashing shutdown", "Stability");
                    if (isUptimeSpanValid)
                    {
                        InstrumentationLogger.LogAnonymousTimedEvent("Stability", "Dirty Uptime", uptimeSpan);
                    }
                    break;

                case ASSUMING_CRASHING_SHUTDOWN_VALUE:
                    //This is the case where we don't know what happened, so we're defaulting
                    InstrumentationLogger.LogAnonymousEvent("Assumed crashing shutdown", "Stability");
                    if (isUptimeSpanValid)
                    {
                        InstrumentationLogger.LogAnonymousTimedEvent("Stability", "Assumed Dirty Uptime", uptimeSpan);
                    }
                    break;

                default:
                    //Something went wrong, fail out with 'unknown' data.
                    InstrumentationLogger.LogAnonymousEvent("Unknown shutdown", "Stability");
                    Debug.WriteLine("Unknown shutdown key value: " + cleanShutdownValue);
                    break;
                }
            }


            // If we don't do anything to explicitly set the type of shutdown assume we hard-crashed
            // this is pesimistic
            Registry.SetValue(REG_KEY, SHUTDOWN_TYPE_NAME, ASSUMING_CRASHING_SHUTDOWN_VALUE);
        }