public EndpointMonitoringStats GetStats()
        {
            var stats = new EndpointMonitoringStats();

            foreach (var monitor in endpoints.Values)
            {
                monitor.AddTo(stats);
            }
            return(stats);
        }
Ejemplo n.º 2
0
 public void AddTo(EndpointMonitoringStats stats)
 {
     if (Monitored)
     {
         if (status == HeartbeatStatus.Alive)
         {
             stats.RecordActive();
         }
         else
         {
             stats.RecordFailing();
         }
     }
 }
        private void Update(EndpointMonitoringStats stats)
        {
            var previousActive = previousStats?.Active ?? 0;
            var previousDead   = previousStats?.Failing ?? 0;

            if (previousActive != stats.Active || previousDead != stats.Failing)
            {
                domainEvents.Raise(new HeartbeatsUpdated
                {
                    Active   = stats.Active,
                    Failing  = stats.Failing,
                    RaisedAt = DateTime.UtcNow
                });
                previousStats = stats;
            }
        }
        async Task Update(EndpointMonitoringStats stats)
        {
            var previousActive = previousStats?.Active ?? 0;
            var previousDead   = previousStats?.Failing ?? 0;

            if (previousActive != stats.Active || previousDead != stats.Failing)
            {
                await domainEvents.Raise(new HeartbeatsUpdated
                {
                    Active   = stats.Active,
                    Failing  = stats.Failing,
                    RaisedAt = DateTime.UtcNow
                }).ConfigureAwait(false);

                previousStats = stats;
            }
        }