示例#1
0
        /// <summary>
        /// Select Seconds Of Type
        /// </summary>
        /// <param name="seconds">Seconds</param>
        /// <returns>Throughput</returns>
        public Throughput SelectSecondsOf(int seconds)
        {
            Contract.Requires <ArgumentOutOfRangeException>(0 < seconds);

            ////Don't Perf; too much logging
            var        time    = DateTime.UtcNow.AddSeconds(-1 * seconds);
            Throughput metrics = null;

            try
            {
                var results = from data in this.generalMetricTable.QueryByPartition(GeneralMetricRow.Partition())
                              where data.Time >= time
                              select data;

                var list = results.ToList();
                metrics = new Throughput()
                {
                    ServerStatistics = list.Sum(m => m.ServerStatisticsCount),
                    Messages         = list.Sum(m => m.MessageCount),
                    EventLog         = list.Sum(m => m.EventLogCount),
                    Exceptions       = list.Sum(m => m.ErrorCount),
                    Performance      = list.Sum(m => m.PerformanceCount),
                };
            }
            catch
            {
                ////Don't log, table misses are frequent
            }

            return(metrics ?? new Throughput());
        }
        public void Time()
        {
            var data = new GeneralMetricRow();
            var item = DateTime.UtcNow;

            data.Time = item;
            Assert.AreEqual <DateTime>(item, data.Time);
        }
        public void ErrorCount()
        {
            var random = new Random();
            var data   = new GeneralMetricRow();
            var item   = random.Next();

            data.ErrorCount = item;
            Assert.AreEqual <long>(item, data.ErrorCount);
        }
        public void ServerStatisticsCount()
        {
            var random = new Random();
            var data   = new GeneralMetricRow();
            var item   = random.Next();

            data.ServerStatisticsCount = item;
            Assert.AreEqual <long>(item, data.ServerStatisticsCount);
        }
示例#5
0
        public void LogMetric(Guid type)
        {
            Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != type);

            //// Do not instrument Performance Metrics, causes recusion

            var metric = new GeneralMetricRow();
            GeneralMetricRow exists = null;

            lock (metricsLock)
            {
                try
                {
                    exists = this.generalMetricTable.QueryBy(metric.PartitionKey, metric.RowKey);
                }
                catch
                {
                    // Do not log, causes recursion
                }

                exists = exists ?? metric;

                if (type == GeneralMetricRow.Error)
                {
                    exists.ErrorCount++;
                }
                else if (type == GeneralMetricRow.EventLog)
                {
                    exists.EventLogCount++;
                }
                else if (type == GeneralMetricRow.Message)
                {
                    exists.MessageCount++;
                }
                else if (type == GeneralMetricRow.Performance)
                {
                    exists.PerformanceCount++;
                }
                else if (type == GeneralMetricRow.ServerStatistics)
                {
                    exists.ServerStatisticsCount++;
                }

                try
                {
                    this.generalMetricTable.AddOrUpdateEntity(exists);
                }
                catch
                {
                    // Do not log, causes recursion
                }
            }
        }
示例#6
0
        public void LogMetric()
        {
            var id  = GeneralMetricRow.ServerStatistics;
            var log = new LogCore();

            log.LogMetric(id);

            var row   = new GeneralMetricRow();
            var table = new AzureTable <GeneralMetricRow>(CloudStorageAccount.DevelopmentStorageAccount);
            var item  = table.QueryBy(row.PartitionKey, row.RowKey);

            Assert.IsTrue(1 <= item.ServerStatisticsCount, item.ServerStatisticsCount.ToString());
        }
 public void PartitionKey()
 {
     Assert.AreEqual <string>(GeneralMetricRow.Partition(), new GeneralMetricRow().PartitionKey);
 }