Esempio n. 1
0
        public IHttpActionResult HealthCheck()
        {
            _loggingService.LogInfo("performing Health check on Blaise connectivity");

            var results = _healthService.PerformCheck().ToList();

            if (results.Any(r => r.StatusType == HealthStatusType.Error))
            {
                return(Content(HttpStatusCode.ServiceUnavailable, results));
            }

            return(Ok());
        }
        private List <HealthCheckResultDto> PerformHealthCheck()
        {
            var timer = new Stopwatch();

            timer.Start();
            var healthCheckResults = _healthService.PerformCheck().ToList();

            timer.Stop();

            var timeTookInSeconds = timer.ElapsedMilliseconds / 1000;

            if (timeTookInSeconds > 5)
            {
                _loggingService.LogWarn($"Health check took '{timeTookInSeconds}' seconds");
            }
            else
            {
                _loggingService.LogInfo($"Health check took '{timeTookInSeconds}' seconds");
            }

            return(healthCheckResults);
        }