The result of a check.
        void ReportToBackend(CheckResult result)
        {
            var sender = Configure.Instance.Builder.Build<ISendMessages>();

            new ServiceControlBackend(sender).Send(new ReportCustomCheckResult
            {
                HostId = hostInfo.HostId,
                Host = hostInfo.Name,
                EndpointName = Configure.EndpointName,
                CustomCheckId = Id,
                Category = Category,
                HasFailed = result.HasFailed,
                FailureReason = result.FailureReason,
                ReportedAt = DateTime.UtcNow
            });
        }
 void DelayExecutionForFail(object state)
 {
     if (Builder != null)
     {
         if (delayExecutionFailTimer != null)
         {
             delayExecutionFailTimer.Dispose();
         }
         ReportToBackend(CheckResult.Failed((string)state));
     }
     else
     {
         if (delayExecutionFailTimer != null)
         {
             delayExecutionFailTimer.Change(2000, -1);
         }
         else
         {
             delayExecutionFailTimer = new Timer(DelayExecutionForFail, state, 2000, -1);
         }
     }
 }
コード例 #3
0
        async Task Run()
        {
            CheckResult result;

            try
            {
                result = await customCheck.PerformCheck().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                var reason = $"'{customCheck.GetType()}' implementation failed to run.";
                result = CheckResult.Failed(reason);
                Logger.Error(reason, ex);
            }

            try
            {
                await ReportToBackend(result, customCheck.Interval.HasValue?TimeSpan.FromTicks( customCheck.Interval.Value.Ticks * 4) : TimeSpan.MaxValue).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to report periodic check to ServiceControl.", ex);
            }
        }
        void ReportToBackend(CheckResult result)
        {
            var sender = Builder.Build<ISendMessages>();

            var serviceControlBackend = new ServiceControlBackend(sender, Configure, CriticalError);
            serviceControlBackend.Send(new ReportCustomCheckResult
            {
                HostId = UnicastBus.HostInformation.HostId,
                Host = UnicastBus.HostInformation.DisplayName,
                EndpointName = Configure.Settings.EndpointName(),
                CustomCheckId = Id,
                Category = Category,
                HasFailed = result.HasFailed,
                FailureReason = result.FailureReason,
                ReportedAt = DateTime.UtcNow
            });
        }
 Task ReportToBackend(CheckResult result, TimeSpan timeToBeReceived)
 {
     return serviceControlBackend.Send(new ReportCustomCheckResult(customCheck.Id, customCheck.Category, result), timeToBeReceived);
 }
コード例 #6
0
 Task ReportToBackend(CheckResult result, TimeSpan timeToBeReceived)
 {
     return(serviceControlBackend.Send(new ReportCustomCheckResult(customCheck.Id, customCheck.Category, result), timeToBeReceived));
 }