예제 #1
0
 public void SampleCount_UsesSample()
 {
     var underTest = new HistogramMetric(new RejectEverythingAboveTenSample());
     underTest.Update(11);
     underTest.Update(2);
     Assert.AreEqual(2, underTest.SampleMin);
 }
예제 #2
0
 public void SampleCount_WhenPassed8And9_Returns2()
 {
     var underTest = new HistogramMetric(HistogramMetric.SampleType.Uniform);
     underTest.Update(9);
     underTest.Update(8);
     Assert.AreEqual(2, underTest.SampleCount);
 }
예제 #3
0
 public void Min_WhenPassed8And9_Returns9()
 {
     var underTest = new HistogramMetric(HistogramMetric.SampleType.Uniform);
     underTest.Update(9);
     underTest.Update(8);
     Assert.AreEqual(8, underTest.Min);
 }
예제 #4
0
 public ManualTimerMetric(
  TimeUnit durationUnit, 
  TimeUnit rateUnit, 
  MeterMetric meter, 
  HistogramMetric histogram, 
  bool clear)
     : base(durationUnit, rateUnit, meter, histogram, clear)
 {
 }
예제 #5
0
 public ManualTimerMetric(
     TimeUnit durationUnit,
     TimeUnit rateUnit,
     MeterMetric meter,
     HistogramMetric histogram,
     bool clear)
     : base(durationUnit, rateUnit, meter, histogram, clear)
 {
 }
예제 #6
0
 protected TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear)
 {
     DurationUnit = durationUnit;
      RateUnit = rateUnit;
      _meter = meter;
      _histogram = histogram;
      if(clear)
      {
     Clear();
      }
 }
예제 #7
0
 protected TimerMetricBase(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear)
 {
     DurationUnit = durationUnit;
     RateUnit     = rateUnit;
     _meter       = meter;
     _histogram   = histogram;
     if (clear)
     {
         Clear();
     }
 }
예제 #8
0
        public void BiasedHistogram_UsesSample()
        {
            var underTest = new HistogramMetric(HistogramMetric.SampleType.Biased);
            var sampleSize = 1028;
            var sample = Enumerable.Range(1, sampleSize).ToList();

            foreach (var s in sample)
            {
                underTest.Update(s);
            }

            Assert.AreEqual(sampleSize, underTest.SampleCount);
            CollectionAssert.AreEquivalent(sample, underTest.Values);
        }
        protected void WriteHistogram(StringBuilder sb, HistogramMetric histogram)
        {
            var percentiles = histogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);

            sb.AppendFormat("               min = %{0:F2}\n", histogram.Min);
            sb.AppendFormat("               max = %{0:F2}\n", histogram.Max);
            sb.AppendFormat("              mean = %{0:F2}\n", histogram.Mean);
            sb.AppendFormat("            stddev = %{0:F2}\n", histogram.StdDev);
            sb.AppendFormat("            median = %{0:F2}\n", percentiles[0]);
            sb.AppendFormat("              75%% <= %{0:F2}\n", percentiles[1]);
            sb.AppendFormat("              95%% <= %{0:F2}\n", percentiles[2]);
            sb.AppendFormat("              98%% <= %{0:F2}\n", percentiles[3]);
            sb.AppendFormat("              99%% <= %{0:F2}\n", percentiles[4]);
            sb.AppendFormat("            99.9%% <= %{0:F2}\n", percentiles[5]);
        }
예제 #10
0
 public void SampleCount_WhenThereAreNoValues_Returns0()
 {
     var underTest = new HistogramMetric(HistogramMetric.SampleType.Uniform);
     Assert.AreEqual(0, underTest.SampleCount);
 }
예제 #11
0
 public void SampleMean_WhenPassed8And9_Returns8Point5()
 {
     var underTest = new HistogramMetric(HistogramMetric.SampleType.Uniform);
     underTest.Update(9);
     underTest.Update(8);
     Assert.AreEqual(8.5, underTest.SampleMean);
 }
예제 #12
0
        private static HistogramData CreateHistogramData(HistogramMetric histogram)
        {
            double[] percentiles = histogram.Percentiles(0.5, 0.75, 0.95, 0.99, 0.999, 0.9999);

            return new HistogramData
                {
                    Counter = histogram.Count,
                    Max = histogram.Max,
                    Mean = histogram.Mean,
                    Min = histogram.Min,
                    Stdev = histogram.StdDev,
                    Percentiles = new Dictionary<string, double>
                    {
                        {"50%", percentiles[0]},
                        {"75%", percentiles[1]},
                        {"95%", percentiles[2]},
                        {"99%", percentiles[3]},
                        {"99.9%", percentiles[4]},
                        {"99.99%", percentiles[5]},
                    }
                };
        }
예제 #13
0
        private void WriteHistogram(HistogramMetric histogram)
        {
            var percentiles = histogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);

            _out.Write("               min = %{0:2}\n", histogram.Min);
            _out.Write("               max = %{0:2}\n", histogram.Max);
            _out.Write("              mean = %{0:2}\n", histogram.Mean);
            _out.Write("            stddev = %{0:2}\n", histogram.StdDev);
            _out.Write("            median = %{0:2}\n", percentiles[0]);
            _out.Write("              75%% <= %{0:2}\n", percentiles[1]);
            _out.Write("              95%% <= %{0:2}\n", percentiles[2]);
            _out.Write("              98%% <= %{0:2}\n", percentiles[3]);
            _out.Write("              99%% <= %{0:2}\n", percentiles[4]);
            _out.Write("            99.9%% <= %{0:2}\n", percentiles[5]);
        }
 public DiskPerformanceStorage()
 {
     WriteLatencyHistogram = new HistogramMetric(HistogramMetric.SampleType.Uniform);
     ReadLatencyHistogram = new HistogramMetric(HistogramMetric.SampleType.Uniform);
     ReadPerSecondHistory = new List<long>();
     WritePerSecondHistory = new List<long>();
     AverageReadLatencyPerSecondHistory = new List<double>();
     AverageWriteLatencyPerSecondHistory = new List<double>();
 }
        private void LogHistogram(IRequest request, MetricName metricName, HistogramMetric metric, long timestamp)
        {
            LogGauge(request, metricName.Name + "." + HistogramMetrics.Max.GetDatadogName(), metric.SampleMax, timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.Min.GetDatadogName(), metric.SampleMin, timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.Mean.GetDatadogName(), metric.SampleMean, timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.StdDev.GetDatadogName(), metric.StdDev, timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.Count.GetDatadogName(), metric.SampleCount, timestamp);

            double[] percentResults = metric.Percentiles(_histogramPercentages);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.At75thPercentile.GetDatadogName(), percentResults[0], timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.At95thPercentile.GetDatadogName(), percentResults[1], timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.At98thPercentile.GetDatadogName(), percentResults[2], timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.At99thPercentile.GetDatadogName(), percentResults[3], timestamp);
            LogGauge(request, metricName.Name + "." + HistogramMetrics.At999thPercentile.GetDatadogName(), percentResults[4], timestamp);

            metric.Clear();
        }