示例#1
0
        private void ReportHistogram(HistogramValueSource g)
        {
            string         name  = g.Name;
            HistogramValue value = GetMetricValueSourceValue <HistogramValue>(g.ValueProvider);
            Unit           unit  = g.Unit;

            Pack(name, HistogramColumns, new object[] {
                value.Count,
                value.LastValue,
                value.LastUserValue ?? "\"\"",
                value.Min,
                value.MinUserValue ?? "\"\"",
                value.Mean,
                value.Max,
                value.MaxUserValue ?? "\"\"",
                value.StdDev,
                value.Median,
                value.Percentile75,
                value.Percentile95,
                value.Percentile98,
                value.Percentile99,
                value.Percentile999,
                value.SampleSize
            }, g.Tags);
        }
示例#2
0
 public TimerValue(MeterValue rate, HistogramValue histogram, long activeSessions, TimeUnit durationUnit)
 {
     Rate           = rate;
     Histogram      = histogram;
     ActiveSessions = activeSessions;
     DurationUnit   = durationUnit;
 }
        public static void HumanizeHistogram(this StringBuilder sb, HistogramValue histogram, Unit unit)
        {
            sb.AppendLine();
            sb.AppendLine("Count".FormatReadableMetricValue(unit.FormatCount(histogram.Count)));
            sb.AppendLine("Last".FormatReadableMetricValue(unit.FormatDuration(histogram.LastValue, null)));

            if (!string.IsNullOrWhiteSpace(histogram.LastUserValue))
            {
                sb.AppendLine("Last User Value".FormatReadableMetricValue(histogram.LastUserValue));
            }

            sb.AppendLine("Min".FormatReadableMetricValue(unit.FormatDuration(histogram.Min, null)));

            if (!string.IsNullOrWhiteSpace(histogram.MinUserValue))
            {
                sb.AppendLine("Min User Value".FormatReadableMetricValue(histogram.MinUserValue));
            }

            sb.AppendLine("Max".FormatReadableMetricValue(unit.FormatDuration(histogram.Max, null)));

            if (!string.IsNullOrWhiteSpace(histogram.MaxUserValue))
            {
                sb.AppendLine("Max User Value".FormatReadableMetricValue(histogram.MaxUserValue));
            }

            sb.AppendLine("Mean".FormatReadableMetricValue(unit.FormatDuration(histogram.Mean, null)));
            sb.AppendLine("StdDev".FormatReadableMetricValue(unit.FormatDuration(histogram.StdDev, null)));
            sb.AppendLine("Median".FormatReadableMetricValue(unit.FormatDuration(histogram.Median, null)));
            sb.AppendLine("75%".FormatReadableMetricValue(unit.FormatDuration(histogram.Percentile75, null), sign: "<="));
            sb.AppendLine("95%".FormatReadableMetricValue(unit.FormatDuration(histogram.Percentile95, null), sign: "<="));
            sb.AppendLine("98%".FormatReadableMetricValue(unit.FormatDuration(histogram.Percentile98, null), sign: "<="));
            sb.AppendLine("99%".FormatReadableMetricValue(unit.FormatDuration(histogram.Percentile99, null), sign: "<="));
            sb.AppendLine("99.9%".FormatReadableMetricValue(unit.FormatDuration(histogram.Percentile999, null), sign: "<="));
        }
示例#4
0
        public void can_hummanize_timer()
        {
            var expected =
                "\r\n\r\n   Active Sessions = 0\r\n        Total Time = 0.00 ms\r\n             Count = 5 Requests\r\n        Mean Value = 1.00 Requests/s\r\n     1 Minute Rate = 2.00 Requests/s\r\n     5 Minute Rate = 3.00 Requests/s\r\n    15 Minute Rate = 4.00 Requests/s\r\n       Total Items = 1\r\n            Item 0 = 00.50%     1 Requests [item]\r\n             Count = 1 Requests\r\n        Mean Value = 2.00 Requests/s\r\n     1 Minute Rate = 3.00 Requests/s\r\n     5 Minute Rate = 4.00 Requests/s\r\n    15 Minute Rate = 5.00 Requests/s\r\n\r\n             Count = 5 Requests\r\n              Last = 0.00 Requests\r\n   Last User Value = 3\r\n               Min = 0.00 Requests\r\n    Min User Value = 8\r\n               Max = 0.00 Requests\r\n    Max User Value = 5\r\n              Mean = 0.00 Requests\r\n            StdDev = 0.00 Requests\r\n            Median = 0.00 Requests\r\n              75% <= 0.00 Requests\r\n              95% <= 0.00 Requests\r\n              98% <= 0.00 Requests\r\n              99% <= 0.00 Requests\r\n            99.9% <= 0.00 Requests\r\n";
            const int count = 5;

            var meterValue = new MeterValue(
                count,
                1,
                2,
                3,
                4,
                TimeUnit.Seconds,
                new[]
            {
                new MeterValue.SetItem("item", 0.5, new MeterValue(1, 2, 3, 4, 5, TimeUnit.Seconds, new MeterValue.SetItem[0]))
            });
            var histogramValue = new HistogramValue(count, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);

            var timerValue       = new TimerValue(meterValue, histogramValue, 0, 1, TimeUnit.Nanoseconds);
            var timerValueSource = new TimerValueSource(
                "test_timer",
                ConstantValue.Provider(timerValue),
                Unit.Requests,
                TimeUnit.Seconds,
                TimeUnit.Milliseconds,
                MetricTags.None);
            var result = timerValueSource.Hummanize();

            Assert.Equal(result, expected);
        }
示例#5
0
        public static TimerValueSource ToMetricValueSource(this Timer source)
        {
            var rateUnit = source.RateUnit.FromUnit();
            var durationUnit = source.DurationUnit.FromUnit();
            var rateValue = new MeterValue(source.Count, source.Rate.MeanRate, source.Rate.OneMinuteRate, source.Rate.FiveMinuteRate,
                source.Rate.FifteenMinuteRate, rateUnit);
            var histogramValue = new HistogramValue(source.Count,
                source.Histogram.LastValue,
                source.Histogram.LastUserValue,
                source.Histogram.Max,
                source.Histogram.MaxUserValue,
                source.Histogram.Mean,
                source.Histogram.Min,
                source.Histogram.MinUserValue,
                source.Histogram.StdDev,
                source.Histogram.Median,
                source.Histogram.Percentile75,
                source.Histogram.Percentile95,
                source.Histogram.Percentile98,
                source.Histogram.Percentile99,
                source.Histogram.Percentile999,
                source.Histogram.SampleSize);

            var timerValue = new TimerValue(rateValue, histogramValue, source.ActiveSessions, source.TotalTime, durationUnit);

            return new TimerValueSource(source.Name, ConstantValue.Provider(timerValue), source.Unit, rateUnit, durationUnit, source.Tags);
        }
示例#6
0
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     if (_isDisposed)
     {
         return;
     }
     Pack("Histogram", name, unit, tags, new[] {
         new JsonProperty("Total-Count", value.Count),
         new JsonProperty("Last", value.LastValue),
         new JsonProperty("Last-User-Value", value.LastUserValue),
         new JsonProperty("Min", value.Min),
         new JsonProperty("Min-User-Value", value.MinUserValue),
         new JsonProperty("Mean", value.Mean),
         new JsonProperty("Max", value.Max),
         new JsonProperty("Max-User-Value", value.MaxUserValue),
         new JsonProperty("StdDev", value.StdDev),
         new JsonProperty("Median", value.Median),
         new JsonProperty("Percentile-75", value.Percentile75),
         new JsonProperty("Percentile-95", value.Percentile95),
         new JsonProperty("Percentile-98", value.Percentile98),
         new JsonProperty("Percentile-99", value.Percentile99),
         new JsonProperty("Percentile-99_9", value.Percentile999),
         new JsonProperty("Sample-Size", value.SampleSize)
     });
 }
示例#7
0
        private IEnumerable <TimerValueSource> SetupTimers()
        {
            const int count = 5;

            var meterValue = new MeterValue(
                count,
                1,
                2,
                3,
                4,
                TimeUnit.Seconds,
                new[]
            {
                new MeterValue.SetItem("item", 0.5, new MeterValue(1, 2, 3, 4, 5, TimeUnit.Seconds, new MeterValue.SetItem[0]))
            });
            var histogramValue = new HistogramValue(count, 1, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);

            var timerValue = new TimerValue(meterValue, histogramValue, 0, TimeUnit.Nanoseconds);
            var timer      = new TimerValueSource(
                TimerNameDefault,
                ConstantValue.Provider(timerValue),
                Unit.Requests,
                TimeUnit.Seconds,
                TimeUnit.Milliseconds,
                Tags);

            return(new[] { timer });
        }
示例#8
0
        private static IEnumerable <JsonProperty> Histogram(HistogramValue value)
        {
            yield return(new JsonProperty("Count", value.Count));

            yield return(new JsonProperty("LastValue", value.LastValue));

            yield return(new JsonProperty("LastUserValue", value.LastUserValue));

            yield return(new JsonProperty("Min", value.Min));

            yield return(new JsonProperty("MinUserValue", value.MinUserValue));

            yield return(new JsonProperty("Mean", value.Mean));

            yield return(new JsonProperty("Max", value.Max));

            yield return(new JsonProperty("MaxUserValue", value.MaxUserValue));

            yield return(new JsonProperty("StdDev", value.StdDev));

            yield return(new JsonProperty("Median", value.Median));

            yield return(new JsonProperty("Percentile75", value.Percentile75));

            yield return(new JsonProperty("Percentile95", value.Percentile95));

            yield return(new JsonProperty("Percentile98", value.Percentile98));

            yield return(new JsonProperty("Percentile99", value.Percentile99));

            yield return(new JsonProperty("Percentile999", value.Percentile999));

            yield return(new JsonProperty("SampleSize", value.SampleSize));
        }
示例#9
0
        private IEnumerable <HistogramValueSource> SetupHistograms()
        {
            var histogramValue = new HistogramValue(1, 1, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);
            var histogram      = new HistogramValueSource(HistogramNameDefault, ConstantValue.Provider(histogramValue), Unit.Items, Tags);

            return(new[] { histogram });
        }
示例#10
0
        public static void AddHistogramValues(
            this HistogramValue histogram,
            IDictionary <string, object> values,
            IDictionary <HistogramFields, string> fields)
        {
            if (values == null)
            {
                return;
            }

            fields.TryAddValuesForKey(values, HistogramFields.Samples, histogram.SampleSize);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.LastValue, histogram.LastValue);
            fields.TryAddValuesForKey(values, HistogramFields.Count, histogram.Count);
            fields.TryAddValuesForKey(values, HistogramFields.Sum, histogram.Sum);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.Min, histogram.Min);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.Max, histogram.Max);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.Mean, histogram.Mean);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.Median, histogram.Median);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.StdDev, histogram.StdDev);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.P999, histogram.Percentile999);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.P99, histogram.Percentile99);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.P98, histogram.Percentile98);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.P95, histogram.Percentile95);
            fields.TryAddValuesForKeyIfNotNanOrInfinity(values, HistogramFields.P75, histogram.Percentile75);
            fields.TryAddValuesForKeyIfPresent(values, HistogramFields.UserLastValue, histogram.LastUserValue);
            fields.TryAddValuesForKeyIfPresent(values, HistogramFields.UserMinValue, histogram.MinUserValue);
            fields.TryAddValuesForKeyIfPresent(values, HistogramFields.UserMaxValue, histogram.MaxUserValue);
        }
示例#11
0
        private static HistogramData ToHistogram(HistogramValue histogram)
        {
            return new HistogramData
            {
                LastValue = histogram.LastValue,
                LastUserValue = histogram.LastUserValue,

                Max = histogram.Max,
                MaxUserValue = histogram.MaxUserValue,

                Mean = histogram.Mean,

                Min = histogram.Min,
                MinUserValue = histogram.MinUserValue,

                StdDev = histogram.StdDev,

                Median = histogram.Median,
                Percentile75 = histogram.Percentile75,
                Percentile95 = histogram.Percentile95,
                Percentile98 = histogram.Percentile98,
                Percentile99 = histogram.Percentile99,
                Percentile999 = histogram.Percentile999,

                SampleSize = histogram.SampleSize,
            };
        }
示例#12
0
        public static void AddHistogramValues(this HistogramValue histogram, IDictionary <string, object> values)
        {
            values.Add("samples", histogram.SampleSize);
            values.Add("last", histogram.LastValue);
            values.Add("count.hist", histogram.Count);
            values.Add("min", histogram.Min);
            values.Add("max", histogram.Max);
            values.Add("mean", histogram.Mean);
            values.Add("median", histogram.Median);
            values.Add("stddev", histogram.StdDev);
            values.Add("p999", histogram.Percentile999);
            values.Add("p99", histogram.Percentile99);
            values.Add("p98", histogram.Percentile98);
            values.Add("p95", histogram.Percentile95);
            values.Add("p75", histogram.Percentile75);

            if (histogram.LastUserValue != null)
            {
                values.Add("user.last", histogram.LastUserValue);
            }

            if (histogram.MinUserValue != null)
            {
                values.Add("user.min", histogram.MinUserValue);
            }

            if (histogram.MaxUserValue != null)
            {
                values.Add("user.max", histogram.MaxUserValue);
            }
        }
示例#13
0
        public IEnumerable <HistogramValueSource> SetupHistograms()
        {
            var histogramValue = new HistogramValue(1, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);
            var histogram      = new HistogramValueSource("test_histgram", ConstantValue.Provider(histogramValue), Unit.Items, Tags);

            return(new[] { histogram });
        }
示例#14
0
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     Send(SubfolderName(name, unit, "Count"), value.Count);
     Send(SubfolderName(name, unit, "Max"), value.Max);
     Send(SubfolderName(name, unit, "Median"), value.Median);
     Send(SubfolderName(name, unit, "p95"), value.Percentile95);
 }
示例#15
0
        protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
        {
            long count = value.Count;

            if (name.Contains(TaggedMetricsRegistry.REPORT_ON_UPDATE_PREFIX))
            {
                string taggedName = "histogram:" + TaggedMetricsRegistry.TagName(name, tags);
                if (reportOnUpdate.ContainsKey(taggedName))
                {
                    if (reportOnUpdate[taggedName] == count)
                    {
                        return;
                    }
                }
                reportOnUpdate[taggedName] = count;
                name = name.Remove(name.IndexOf(TaggedMetricsRegistry.REPORT_ON_UPDATE_PREFIX), TaggedMetricsRegistry.REPORT_ON_UPDATE_PREFIX.Length);
            }

            AddCumulativeCounter(SubfolderName(name, unit, "Count"), count, tags, MetricDetails.count);
            AddGauge(SubfolderName(name, unit, "Last"), value.LastValue, tags, MetricDetails.last);
            AddGauge(SubfolderName(name, unit, "Min"), value.Min, tags, MetricDetails.min);
            AddGauge(SubfolderName(name, unit, "Mean"), value.Mean, tags, MetricDetails.mean);
            AddGauge(SubfolderName(name, unit, "Max"), value.Max, tags, MetricDetails.max);
            AddGauge(SubfolderName(name, unit, "StdDev"), value.StdDev, tags, MetricDetails.stddev);
            AddGauge(SubfolderName(name, unit, "Median"), value.Median, tags, MetricDetails.median);
            AddGauge(SubfolderName(name, unit, "p75"), value.Percentile75, tags, MetricDetails.percent_75);
            AddGauge(SubfolderName(name, unit, "p95"), value.Percentile95, tags, MetricDetails.percent_95);
            AddGauge(SubfolderName(name, unit, "p98"), value.Percentile98, tags, MetricDetails.percent_98);
            AddGauge(SubfolderName(name, unit, "p99"), value.Percentile99, tags, MetricDetails.percent_99);
            AddGauge(SubfolderName(name, unit, "p999"), value.Percentile999, tags, MetricDetails.percent_999);
        }
示例#16
0
        private static HistogramData ToHistogram(HistogramValue histogram)
        {
            return(new HistogramData
            {
                LastValue = histogram.LastValue,
                LastUserValue = histogram.LastUserValue,

                Max = histogram.Max,
                MaxUserValue = histogram.MaxUserValue,

                Mean = histogram.Mean,

                Min = histogram.Min,
                MinUserValue = histogram.MinUserValue,

                StdDev = histogram.StdDev,

                Median = histogram.Median,
                Percentile75 = histogram.Percentile75,
                Percentile95 = histogram.Percentile95,
                Percentile98 = histogram.Percentile98,
                Percentile99 = histogram.Percentile99,
                Percentile999 = histogram.Percentile999,

                SampleSize = histogram.SampleSize,
            });
        }
        public void histogram_can_use_custom_data_keys_and_should_provide_corresponding_values()
        {
            // Arrange
            var value    = new HistogramValue(1, 1, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);
            var data     = new Dictionary <string, object>();
            var dataKeys = new MetricValueDataKeys(
                histogram: new Dictionary <HistogramValueDataKeys, string>
            {
                { HistogramValueDataKeys.UserLastValue, "userLastValue" },
                { HistogramValueDataKeys.UserMinValue, "userMinValue" },
                { HistogramValueDataKeys.UserMaxValue, "userMaxValue" },
                { HistogramValueDataKeys.P75, "75th_percentile" }
            });

            // Act
            value.AddHistogramValues(data, dataKeys.Histogram);

            // Assert
            data.ContainsKey(DataKeys.Histogram[HistogramValueDataKeys.UserLastValue]).Should().BeFalse();
            data["userLastValue"].Should().Be("3");
            data.ContainsKey(DataKeys.Histogram[HistogramValueDataKeys.UserMaxValue]).Should().BeFalse();
            data["userMaxValue"].Should().Be("5");
            data.ContainsKey(DataKeys.Histogram[HistogramValueDataKeys.UserMinValue]).Should().BeFalse();
            data["userMinValue"].Should().Be("8");
            data.ContainsKey(DataKeys.Histogram[HistogramValueDataKeys.P75]).Should().BeFalse();
            data["75th_percentile"].Should().Be(11.0);
        }
        public void histogram_default_data_keys_should_provide_corresponding_values()
        {
            // Arrange
            var value = new HistogramValue(1, 1, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);
            var data  = new Dictionary <string, object>();

            // Act
            value.AddHistogramValues(data, DataKeys.Histogram);

            // Assert
            data[DataKeys.Histogram[HistogramValueDataKeys.Count]].Should().Be(1L);
            data[DataKeys.Histogram[HistogramValueDataKeys.Sum]].Should().Be(1.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.LastValue]].Should().Be(2.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.UserLastValue]].Should().Be("3");
            data[DataKeys.Histogram[HistogramValueDataKeys.Max]].Should().Be(4.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.UserMaxValue]].Should().Be("5");
            data[DataKeys.Histogram[HistogramValueDataKeys.Mean]].Should().Be(6.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.Min]].Should().Be(7.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.UserMinValue]].Should().Be("8");
            data[DataKeys.Histogram[HistogramValueDataKeys.StdDev]].Should().Be(9.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.Median]].Should().Be(10.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.P75]].Should().Be(11.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.P95]].Should().Be(12.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.P98]].Should().Be(13.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.P99]].Should().Be(14.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.P999]].Should().Be(15.0);
            data[DataKeys.Histogram[HistogramValueDataKeys.Samples]].Should().Be(16);
        }
        private void WriteHistogram(HistogramValue value, Unit unit, TimeUnit?durationUnit = null)
        {
            WriteValue("Count", unit.FormatCount(value.Count));
            WriteValue("Last", unit.FormatDuration(value.LastValue, durationUnit));

            if (!string.IsNullOrWhiteSpace(value.LastUserValue))
            {
                WriteValue("Last User Value", value.LastUserValue);
            }

            WriteValue("Min", unit.FormatDuration(value.Min, durationUnit));

            if (!string.IsNullOrWhiteSpace(value.MinUserValue))
            {
                WriteValue("Min User Value", value.MinUserValue);
            }

            WriteValue("Max", unit.FormatDuration(value.Max, durationUnit));

            if (!string.IsNullOrWhiteSpace(value.MaxUserValue))
            {
                WriteValue("Max User Value", value.MaxUserValue);
            }

            WriteValue("Mean", unit.FormatDuration(value.Mean, durationUnit));
            WriteValue("StdDev", unit.FormatDuration(value.StdDev, durationUnit));
            WriteValue("Median", unit.FormatDuration(value.Median, durationUnit));
            WriteValue("75%", unit.FormatDuration(value.Percentile75, durationUnit), sign: "<=");
            WriteValue("95%", unit.FormatDuration(value.Percentile95, durationUnit), sign: "<=");
            WriteValue("98%", unit.FormatDuration(value.Percentile98, durationUnit), sign: "<=");
            WriteValue("99%", unit.FormatDuration(value.Percentile99, durationUnit), sign: "<=");
            WriteValue("99.9%", unit.FormatDuration(value.Percentile999, durationUnit), sign: "<=");
        }
示例#20
0
        public static HistogramValueSource ToMetricValueSource(this Histogram source)
        {
            var histogramValue = new HistogramValue(source.Count, source.LastValue, source.LastUserValue,
                                                    source.Max, source.MaxUserValue, source.Mean, source.Min, source.MinUserValue, source.StdDev, source.Median,
                                                    source.Percentile75, source.Percentile95, source.Percentile98, source.Percentile99, source.Percentile999, source.SampleSize);

            return(new HistogramValueSource(source.Name, ConstantValue.Provider(histogramValue), source.Unit, source.Tags));
        }
 internal static void CopyTo(this HistogramValue value, MetricTelemetry mt)
 {
     mt.Sum               = value.Sum;
     mt.Count             = Convert.ToInt32(value.Count);
     mt.Min               = value.Min;
     mt.Max               = value.Max;
     mt.StandardDeviation = value.StdDev;
 }
示例#22
0
        public HistogramValueSource ToValueSource()
        {
            var histogramValue = new HistogramValue(this.Count, this.LastValue, this.LastUserValue,
                                                    this.Max, this.MaxUserValue, this.Mean, this.Min, this.MinUserValue, this.StdDev, this.Median,
                                                    this.Percentile75, this.Percentile95, this.Percentile98, this.Percentile99, this.Percentile999, this.SampleSize, this.Sum);

            return(new HistogramValueSource(this.Name, ConstantValue.Provider(histogramValue), this.Unit, this.Tags));
        }
示例#23
0
 public PercentilesUs(HistogramValue valueSource)
 {
     _10000 = valueSource.Max;
     _999   = valueSource.Percentile999;
     _980   = valueSource.Percentile98;
     _950   = valueSource.Percentile95;
     _750   = valueSource.Percentile75;
 }
示例#24
0
 public HistogramValue GetValue(bool resetMetric = false)
 {
     var value = new HistogramValue(this.last.Value, this.last.UserValue, this.reservoir.GetSnapshot(resetMetric));
     if (resetMetric)
     {
         this.last = new UserValueWrapper();
     }
     return value;
 }
 private static void TranslateHistogram(HistogramValue value, MetricTelemetry mt, string type)
 {
     mt.Sum               = value.Sum;
     mt.Count             = Convert.ToInt32(value.Count);
     mt.Min               = value.Min;
     mt.Max               = value.Max;
     mt.StandardDeviation = value.StdDev;
     mt.Properties[Constants.AppMetricsTypeKey] = type;
 }
示例#26
0
        public void can_hummanize_histogram()
        {
            var expected =
                "\r\n             Count = 1 Items\r\n              Last = 2.00 Items\r\n   Last User Value = 3\r\n               Min = 7.00 Items\r\n    Min User Value = 8\r\n               Max = 4.00 Items\r\n    Max User Value = 5\r\n              Mean = 6.00 Items\r\n            StdDev = 9.00 Items\r\n            Median = 10.00 Items\r\n              75% <= 11.00 Items\r\n              95% <= 12.00 Items\r\n              98% <= 13.00 Items\r\n              99% <= 14.00 Items\r\n            99.9% <= 15.00 Items\r\n";
            var histogramValue       = new HistogramValue(1, 2, "3", 4, "5", 6, 7, "8", 9, 10, 11, 12, 13, 14, 15, 16);
            var histogramValueSource = new HistogramValueSource("test_histgram", ConstantValue.Provider(histogramValue), Unit.Items, MetricTags.None);
            var result = histogramValueSource.Hummanize();

            Assert.Equal(result, expected);
        }
示例#27
0
        /// <inheritdoc />
        public HistogramValue GetValue(bool resetMetric = false)
        {
            var value = new HistogramValue(_last.Value, _last.UserValue, _reservoir.GetSnapshot(resetMetric));

            if (resetMetric)
            {
                _last = UserValueWrapper.Empty;
            }
            return(value);
        }
示例#28
0
 public TimerHistogram(HistogramValue histogram)
 {
     Last   = histogram.LastValue;
     Mean   = histogram.Mean;
     Median = histogram.Median;
     StdDev = histogram.StdDev;
     Max    = histogram.Max;
     Min    = histogram.Min;
     P999   = histogram.Percentile999;
     P99    = histogram.Percentile99;
     P98    = histogram.Percentile98;
     P95    = histogram.Percentile95;
     P75    = histogram.Percentile75;
 }
示例#29
0
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     Send(SubfolderName(name, unit, "Count"), value.Count);
     Send(SubfolderName(name, unit, "Last"), value.LastValue);
     Send(SubfolderName(name, unit, "Min"), value.Min);
     Send(SubfolderName(name, unit, "Mean"), value.Mean);
     Send(SubfolderName(name, unit, "Max"), value.Max);
     Send(SubfolderName(name, unit, "StdDev"), value.StdDev);
     Send(SubfolderName(name, unit, "Median"), value.Median);
     Send(SubfolderName(name, unit, "p75"), value.Percentile75);
     Send(SubfolderName(name, unit, "p95"), value.Percentile95);
     Send(SubfolderName(name, unit, "p98"), value.Percentile98);
     Send(SubfolderName(name, unit, "p99"), value.Percentile99);
     Send(SubfolderName(name, unit, "p99,9"), value.Percentile999);
 }
示例#30
0
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     Send(SubfolderName(name, unit, "Count"), value.Count, this.lastTimestamp);
     Send(SubfolderName(name, unit, "Last"), value.LastValue, this.lastTimestamp);
     Send(SubfolderName(name, unit, "Min"), value.Min, this.lastTimestamp);
     Send(SubfolderName(name, unit, "Mean"), value.Mean, this.lastTimestamp);
     Send(SubfolderName(name, unit, "Max"), value.Max, this.lastTimestamp);
     Send(SubfolderName(name, unit, "StdDev"), value.StdDev, this.lastTimestamp);
     Send(SubfolderName(name, unit, "p75"), value.Median, this.lastTimestamp);
     Send(SubfolderName(name, unit, "p95"), value.Percentile75, this.lastTimestamp);
     Send(SubfolderName(name, unit, "p95"), value.Percentile95, this.lastTimestamp);
     Send(SubfolderName(name, unit, "p98"), value.Percentile98, this.lastTimestamp);
     Send(SubfolderName(name, unit, "p99"), value.Percentile99, this.lastTimestamp);
     Send(SubfolderName(name, unit, "p99,9"), value.Percentile999, this.lastTimestamp);
 }
示例#31
0
        public TimerValueSource ToValueSource()
        {
            var rateUnit     = TimeUnitExtensions.FromUnit(this.RateUnit);
            var durationUnit = TimeUnitExtensions.FromUnit(this.DurationUnit);

            var rateValue      = new MeterValue(this.Count, this.Rate.MeanRate, this.Rate.OneMinuteRate, this.Rate.FiveMinuteRate, this.Rate.FifteenMinuteRate, rateUnit);
            var histogramValue = new HistogramValue(this.Count,
                                                    this.Histogram.LastValue, this.Histogram.LastUserValue,
                                                    this.Histogram.Max, this.Histogram.MaxUserValue, this.Histogram.Mean,
                                                    this.Histogram.Min, this.Histogram.MinUserValue, this.Histogram.StdDev, this.Histogram.Median,
                                                    this.Histogram.Percentile75, this.Histogram.Percentile95, this.Histogram.Percentile98,
                                                    this.Histogram.Percentile99, this.Histogram.Percentile999, this.Histogram.SampleSize);

            var timerValue = new TimerValue(rateValue, histogramValue, this.ActiveSessions, this.TotalTime, durationUnit);

            return(new TimerValueSource(this.Name, ConstantValue.Provider(timerValue), this.Unit, rateUnit, durationUnit, this.Tags));
        }
示例#32
0
        private static IEnumerable<Value> HistogramValues(HistogramValue value, Unit unit, TimeUnit? timeUnit = null)
        {
            yield return new Value("Last", value.LastValue);
            yield return new Value("Last User Value", value.LastUserValue);
            yield return new Value("Min", value.Min);
            yield return new Value("Min User Value", value.MinUserValue);
            yield return new Value("Max", value.Max);
            yield return new Value("Max User Value", value.MaxUserValue);
            yield return new Value("Mean", value.Mean);
            yield return new Value("StdDev", value.StdDev);
            yield return new Value("Median", value.Median);
            yield return new Value("75%", value.Percentile75);
            yield return new Value("95%", value.Percentile95);
            yield return new Value("98%", value.Percentile98);
            yield return new Value("99%", value.Percentile99);
            yield return new Value("99.9%", value.Percentile999);

            if (timeUnit.HasValue)
            {
                yield return new Value("Unit", timeUnit.Value.Unit());
            }
            else
            {
                if (!string.IsNullOrEmpty(unit.Name))
                {
                    yield return new Value("Unit", unit.Name);
                }
            }
        }
示例#33
0
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     Write("Histogram", name, HistogramValues(value, unit));
 }
示例#34
0
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     Pack("Histogram", name, unit, tags, new[] { 
         new JsonProperty("Total Count",value.Count),
         new JsonProperty("Last", value.LastValue),
         new JsonProperty("Last User Value", value.LastUserValue),
         new JsonProperty("Min",value.Min),
         new JsonProperty("Min User Value",value.MinUserValue),
         new JsonProperty("Mean",value.Mean),
         new JsonProperty("Max",value.Max),
         new JsonProperty("Max User Value",value.MaxUserValue),
         new JsonProperty("StdDev",value.StdDev),
         new JsonProperty("Median",value.Median),
         new JsonProperty("Percentile 75%",value.Percentile75),
         new JsonProperty("Percentile 95%",value.Percentile95),
         new JsonProperty("Percentile 98%",value.Percentile98),
         new JsonProperty("Percentile 99%",value.Percentile99),
         new JsonProperty("Percentile 99.9%" ,value.Percentile999),
         new JsonProperty("Sample Size", value.SampleSize)
     });
 }
示例#35
0
        public TimerValueSource ToValueSource()
        {
            var rateUnit = TimeUnitExtensions.FromUnit(this.RateUnit);
            var durationUnit = TimeUnitExtensions.FromUnit(this.DurationUnit);

            var rateValue = new MeterValue(this.Count, this.Rate.MeanRate, this.Rate.OneMinuteRate, this.Rate.FiveMinuteRate, this.Rate.FifteenMinuteRate, rateUnit);
            var histogramValue = new HistogramValue(this.Count,
                this.Histogram.LastValue, this.Histogram.LastUserValue,
                this.Histogram.Max, this.Histogram.MaxUserValue, this.Histogram.Mean,
                this.Histogram.Min, this.Histogram.MinUserValue, this.Histogram.StdDev, this.Histogram.Median,
                this.Histogram.Percentile75, this.Histogram.Percentile95, this.Histogram.Percentile98,
                this.Histogram.Percentile99, this.Histogram.Percentile999, this.Histogram.SampleSize);

            var timerValue = new TimerValue(rateValue, histogramValue, this.ActiveSessions, durationUnit);

            return new TimerValueSource(this.Name, ConstantValue.Provider(timerValue), this.Unit, rateUnit, durationUnit, this.Tags);
        }
示例#36
0
        public HistogramValueSource ToValueSource()
        {
            var histogramValue = new HistogramValue(this.Count, this.LastValue, this.LastUserValue,
                this.Max, this.MaxUserValue, this.Mean, this.Min, this.MinUserValue, this.StdDev, this.Median,
                this.Percentile75, this.Percentile95, this.Percentile98, this.Percentile99, this.Percentile999, this.SampleSize);

            return new HistogramValueSource(this.Name, ConstantValue.Provider(histogramValue), this.Unit, this.Tags);
        }
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
     this.WriteMetricName(name);
     this.WriteHistogram(value, unit);
 }
        private void WriteHistogram(HistogramValue value, Unit unit, TimeUnit? durationUnit = null)
        {
            WriteValue("Count", unit.FormatCount(value.Count));
            WriteValue("Last", unit.FormatDuration(value.LastValue, durationUnit));

            if (!string.IsNullOrWhiteSpace(value.LastUserValue))
            {
                WriteValue("Last User Value", value.LastUserValue);
            }

            WriteValue("Min", unit.FormatDuration(value.Min, durationUnit));

            if (!string.IsNullOrWhiteSpace(value.MinUserValue))
            {
                WriteValue("Min User Value", value.MinUserValue);
            }

            WriteValue("Max", unit.FormatDuration(value.Max, durationUnit));

            if (!string.IsNullOrWhiteSpace(value.MaxUserValue))
            {
                WriteValue("Max User Value", value.MaxUserValue);
            }

            WriteValue("Mean", unit.FormatDuration(value.Mean, durationUnit));
            WriteValue("StdDev", unit.FormatDuration(value.StdDev, durationUnit));
            WriteValue("Median", unit.FormatDuration(value.Median, durationUnit));
            WriteValue("75%", unit.FormatDuration(value.Percentile75, durationUnit), sign: "<=");
            WriteValue("95%", unit.FormatDuration(value.Percentile95, durationUnit), sign: "<=");
            WriteValue("98%", unit.FormatDuration(value.Percentile98, durationUnit), sign: "<=");
            WriteValue("99%", unit.FormatDuration(value.Percentile99, durationUnit), sign: "<=");
            WriteValue("99.9%", unit.FormatDuration(value.Percentile999, durationUnit), sign: "<=");
        }
 protected override void ReportHistogram(string name, HistogramValue value, Unit unit, MetricTags tags)
 {
   this.metricName = name;
   base.ReportHistogram(name, value, unit, tags);
 }
示例#40
0
 private static IEnumerable<JsonProperty> Histogram(HistogramValue value)
 {
     yield return new JsonProperty("Count", value.Count);
     yield return new JsonProperty("LastValue", value.LastValue);
     yield return new JsonProperty("Min", value.Min);
     yield return new JsonProperty("Mean", value.Mean);
     yield return new JsonProperty("Max", value.Max);
     yield return new JsonProperty("StdDev", value.StdDev);
     yield return new JsonProperty("Median", value.Median);
     yield return new JsonProperty("Percentile75", value.Percentile75);
     yield return new JsonProperty("Percentile95", value.Percentile95);
     yield return new JsonProperty("Percentile98", value.Percentile98);
     yield return new JsonProperty("Percentile99", value.Percentile99);
     yield return new JsonProperty("Percentile999", value.Percentile999);
     yield return new JsonProperty("SampleSize", value.SampleSize);
 }