示例#1
0
        public override async Task <HealthTestResult> TestHealthAsync(List <AnalyticsTrackedEvent> events)
        {
            // retry file preparation for any unprepared paths
            List <string> pathsUnpreparedForRemote;

            lock (_pathsUnpreparedForRemote)
            {
                pathsUnpreparedForRemote = _pathsUnpreparedForRemote.ToList();
            }

            foreach (string pathUnpreparedForRemote in pathsUnpreparedForRemote)
            {
                await PreparePathForRemoteAsync(pathUnpreparedForRemote, CancellationToken.None);
            }

            HealthTestResult result = await base.TestHealthAsync(events);

            string eventName = TrackedEvent.Health + ":" + GetType().Name;
            Dictionary <string, string> properties = new Dictionary <string, string>
            {
                { "Percent Buffer Written To File", Convert.ToString(_totalDataWritten.RoundToWholePercentageOf(_totalDataBuffered, 5)) },
                { "Percent Files Closed", Convert.ToString(_totalFilesClosed.RoundToWholePercentageOf(_currentPath == null ? _totalFilesOpened : _totalFilesOpened - 1, 5)) },  // don't count the currently open file in the denominator. we want the number to reflect the extent to which all files that should have been closed indeed were.
                { "Percent Closed Files Prepared For Remote", Convert.ToString(_totalFilesPreparedForRemote.RoundToWholePercentageOf(_totalFilesClosed, 5)) },
                { "Percent Closed Files Written To Remote", Convert.ToString(_totalFilesWrittenToRemote.RoundToWholePercentageOf(_totalFilesClosed, 5)) },
                { "Paths Unprepared For Remote", Convert.ToString(_pathsUnpreparedForRemote.Count) },
                { "Prepared Files Size MB", Convert.ToString(Math.Round(GetSizeMB(), 0)) }
            };

            Analytics.TrackEvent(eventName, properties);

            events.Add(new AnalyticsTrackedEvent(eventName, properties));

            return(result);
        }
示例#2
0
        public async Task <HealthTestResult> Test()
        {
            var result = new HealthTestResult();

            Logger.Trace("BEGIN | Matrix.Server.Log.Database.HealthRepository.Test");

            DbConnection connection = null;

            try
            {
                using (connection = GetDbConnection())
                {
                    await connection.OpenAsync();

                    result.Status = true;
                    result.Text   = "OK";

                    connection.Close();
                }
            }
            catch (Exception e)
            {
                Logger.Trace("ERROR | Matrix.Server.Log.Database.HealthRepository.Test");
                Logger.Error(e);

                result.Status = false;
                result.Text   = e.Message;
            }

            Logger.Trace("END | Matrix.Server.Log.Database.ApplicationRepository.Test");

            return(result);
        }
示例#3
0
        public override async Task <HealthTestResult> TestHealthAsync(List <AnalyticsTrackedEvent> events)
        {
            HealthTestResult result = await base.TestHealthAsync(events);

            if (State == ProbeState.Running)
            {
                // if the user disables/enables BT manually, we will no longer be advertising the service. start advertising
                // on each health test to ensure we're advertising.
                StartAdvertising();
            }

            return(result);
        }
示例#4
0
        public override async Task<HealthTestResult> TestHealthAsync(List<AnalyticsTrackedEvent> events)
        {
            HealthTestResult result = await base.TestHealthAsync(events);

            string eventName = TrackedEvent.Health + ":" + GetType().Name;
            Dictionary<string, string> properties = new Dictionary<string, string>
            {
                { "Put Success", Convert.ToString(_successfulPutCount.RoundToWholePercentageOf(_putCount, 5)) }
            };

            Analytics.TrackEvent(eventName, properties);

            events.Add(new AnalyticsTrackedEvent(eventName, properties));

            return result;
        }
示例#5
0
        public virtual Task <HealthTestResult> TestHealthAsync(List <AnalyticsTrackedEvent> events)
        {
            HealthTestResult result = HealthTestResult.Okay;

            if (!_running)
            {
                result = HealthTestResult.Restart;
            }

            string eventName = TrackedEvent.Health + ":" + GetType().Name;
            Dictionary <string, string> properties = new Dictionary <string, string>
            {
                { "Running", _running.ToString() }
            };

            Analytics.TrackEvent(eventName, properties);

            events.Add(new AnalyticsTrackedEvent(eventName, properties));

            return(Task.FromResult(result));
        }
示例#6
0
        public override async Task <HealthTestResult> TestHealthAsync(List <AnalyticsTrackedEvent> events)
        {
            HealthTestResult result = await base.TestHealthAsync(events);

            if (_mostRecentSuccessfulWriteTime.HasValue)
            {
                TimeSpan timeElapsedSincePreviousWrite = DateTime.Now - _mostRecentSuccessfulWriteTime.Value;
                if (timeElapsedSincePreviousWrite.TotalMilliseconds > (_writeDelayMS + 5000))  // system timer callbacks aren't always fired exactly as scheduled, resulting in health tests that identify warning conditions for delayed data storage. allow a small fudge factor to ignore most of these warnings.
                {
                    string eventName = TrackedEvent.Warning + ":" + GetType().Name;
                    Dictionary <string, string> properties = new Dictionary <string, string>
                    {
                        { "Storage Latency", (timeElapsedSincePreviousWrite.TotalMilliseconds).RoundToWhole(1000).ToString() }
                    };

                    Analytics.TrackEvent(eventName, properties);

                    events.Add(new AnalyticsTrackedEvent(eventName, properties));
                }
            }

            if (!SensusContext.Current.CallbackScheduler.ContainsCallback(_writeCallback))
            {
                string eventName = TrackedEvent.Error + ":" + GetType().Name;
                Dictionary <string, string> properties = new Dictionary <string, string>
                {
                    { "Missing Callback", _writeCallback.Id }
                };

                Analytics.TrackEvent(eventName, properties);

                events.Add(new AnalyticsTrackedEvent(eventName, properties));

                result = HealthTestResult.Restart;
            }

            return(result);
        }
示例#7
0
        public virtual Task <HealthTestResult> TestHealthAsync(List <AnalyticsTrackedEvent> events)
        {
            HealthTestResult result = HealthTestResult.Okay;

            lock (_stateLocker)
            {
                string eventName = TrackedEvent.Health + ":" + GetType().Name;
                Dictionary <string, string> properties = new Dictionary <string, string>
                {
                    { "State", _state.ToString() }
                };

                // we'll only have data rates if the probe is running -- it might have failed to start.
                if (_state == ProbeState.Running)
                {
                    double?rawDataPerSecond           = _rawRateCalculator.GetDataPerSecond();
                    double?storedDataPerSecond        = _storageRateCalculator.GetDataPerSecond();
                    double?percentageNominalStoreRate = null;
                    if (storedDataPerSecond.HasValue && MaxDataStoresPerSecond.HasValue)
                    {
                        percentageNominalStoreRate = (storedDataPerSecond.Value / MaxDataStoresPerSecond.Value) * 100;
                    }

                    properties.Add("Percentage Nominal Storage Rate", Convert.ToString(percentageNominalStoreRate?.RoundToWhole(5)));

                    Analytics.TrackEvent(eventName, properties);

                    // we don't have a great way of tracking data rates, as they are continuous values and event tracking is string-based. so,
                    // just add the rates to the properties after event tracking. this way it will still be included in the status.
                    properties.Add("Raw Data / Second", Convert.ToString(rawDataPerSecond));
                    properties.Add("Stored Data / Second", Convert.ToString(storedDataPerSecond));
                }

                events.Add(new AnalyticsTrackedEvent(eventName, properties));
            }

            return(Task.FromResult(result));
        }
示例#8
0
        public async Task <HealthTestResult> Test()
        {
            HealthTestResult result = null;

            Logger.Trace("BEGIN | Matrix.Server.Log.Business.HealthService.Test");

            try
            {
                if (Repository != null)
                {
                    result = await Repository.Test();
                }
            }
            catch (Exception e)
            {
                Logger.Trace("ERROR | Matrix.Server.Log.Business.HealthService.Test");
                Logger.Error(e);
            }

            Logger.Trace("END | Matrix.Server.Log.Business.HealthService.Test");

            return(result);
        }