コード例 #1
0
        private object ProcessError(IMessage <Error> message)
        {
            Error value = message.GetBody();

            if (value == null)
            {
                return(null);
            }

            _stats.Counter(StatNames.ErrorsDequeued);
            using (_stats.StartTimer(StatNames.ErrorsProcessingTime))
                _errorPipeline.Run(value);

            return(null);
        }
コード例 #2
0
        public void CanGetMinuteStats()
        {
            TimeSpan  timeOffset   = _projectRepository.GetDefaultTimeOffset(TestConstants.ProjectId);
            DateTime  startDate    = new DateTime(DateTime.UtcNow.Ticks, DateTimeKind.Unspecified).Add(timeOffset);
            DateTime  utcStartDate = new DateTimeOffset(startDate, timeOffset).UtcDateTime;
            DateTime  endDate      = startDate.AddDays(2);
            DateTime  utcEndDate   = new DateTimeOffset(endDate, timeOffset).UtcDateTime;
            const int count        = 100;

            List <Error>   errors = ErrorData.GenerateErrors(count, startDate: startDate, endDate: endDate, errorStackId: TestConstants.ErrorStackId, projectId: TestConstants.ProjectId, timeZoneOffset: timeOffset).ToList();
            DateTimeOffset first  = errors.Min(e => e.OccurrenceDate);

            Assert.True(first >= utcStartDate);
            DateTimeOffset last = errors.Max(e => e.OccurrenceDate);

            Assert.True(last <= utcEndDate);
            _errorPipeline.Run(errors);

            var info = _errorStatsHelper.GetProjectErrorStatsByMinuteBlock(TestConstants.ProjectId, timeOffset, startDate, endDate);

            Assert.Equal(count, info.Total);
            Assert.Equal(1, info.UniqueTotal);
            Assert.Equal(0, info.NewTotal);
            //Assert.Equal(1, info.Stats.Count);
            Assert.Equal(count, info.Stats.Sum(ds => ds.Total));
            Assert.True(info.Stats.All(ds => ds.UniqueTotal <= 1));
            Assert.Equal(0, info.Stats.Sum(ds => ds.NewTotal));
        }