Exemple #1
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);
        }
Exemple #2
0
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit)
        {
            var values = MeterValues(value.Rate.Scale(rateUnit), unit, rateUnit)
                .Concat(HistogramValues(value.Histogram.Scale(durationUnit), unit, durationUnit));

            Write("Timer", name, values);
        }
Exemple #3
0
        private void ReportTimer(TimerValueSource g)
        {
            string     name         = g.Name;
            TimerValue value        = GetMetricValueSourceValue <TimerValue>(g.ValueProvider);
            Unit       unit         = g.Unit;
            TimeUnit   rateUnit     = g.RateUnit;
            TimeUnit   durationUnit = g.DurationUnit;

            Pack(name, TimerColumns, new object[] {
                value.Rate.Count,
                value.ActiveSessions,
                value.Rate.MeanRate,
                value.Rate.OneMinuteRate,
                value.Rate.FiveMinuteRate,
                value.Rate.FifteenMinuteRate,
                value.Histogram.LastValue,
                value.Histogram.LastUserValue ?? "\"\"",
                value.Histogram.Min,
                value.Histogram.MinUserValue ?? "\"\"",
                value.Histogram.Mean,
                value.Histogram.Max,
                value.Histogram.MaxUserValue ?? "\"\"",
                value.Histogram.StdDev,
                value.Histogram.Median,
                value.Histogram.Percentile75,
                value.Histogram.Percentile95,
                value.Histogram.Percentile98,
                value.Histogram.Percentile99,
                value.Histogram.Percentile999,
                value.Histogram.SampleSize
            }, g.Tags);
        }
        public JsonSerializationTests()
        {
            var eventFields = new Dictionary <string, object>();

            eventFields.Add("field", "value");
            eventFields.Add("abc", "123");
            eventValue = new EventValue(new List <EventDetails>
            {
                new EventDetails(eventFields, new DateTime(1, 1, 1))
            });

            this.timerValue = new TimerValue(this.meterValue, this.histogramValue, 0, 1, TimeUnit.Nanoseconds);

            this.counter   = new CounterValueSource("test1", Provider(counterValue), Unit.Errors, MetricTags.None);
            this.meter     = new MeterValueSource("test2", Provider(meterValue), Unit.Calls, TimeUnit.Seconds, MetricTags.None);
            this.histogram = new HistogramValueSource("test3", Provider(histogramValue), Unit.Items, MetricTags.None);
            this.timer     = new TimerValueSource("test4", Provider(timerValue), Unit.Requests, TimeUnit.Seconds, TimeUnit.Milliseconds, MetricTags.None);
            this.evnt      = new EventValueSource("test5", Provider(eventValue), MetricTags.None);

            this.data = new MetricsData("test", new DateTime(2014, 2, 17), new[] { new EnvironmentEntry("name", "1") },
                                        new[] { gauge }, new[] { counter }, new[] { meter }, new[] { histogram }, new[] { timer }, new[] { evnt },
                                        Enumerable.Empty <MetricsData>()
                                        );
            this.jsonContext = JsonMetricsContext.FromContext(this.data, "1");
        }
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     Send(SubfolderName(name, unit, "Count"), value.Rate.Count);
     Send(SubfolderName(name, durationUnit.Unit(), "Duration-Max"), value.Histogram.Max);
     Send(SubfolderName(name, durationUnit.Unit(), "Duration-Median"), value.Histogram.Median);
     Send(SubfolderName(name, durationUnit.Unit(), "Duration-p95"), value.Histogram.Percentile95);
 }
Exemple #6
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 });
        }
Exemple #7
0
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     this.WriteMetricName(name);
     this.WriteValue("Active Sessions", value.ActiveSessions.ToString());
     this.WriteMeter(value.Rate, unit, rateUnit);
     this.WriteHistogram(value.Histogram, unit, durationUnit);
 }
Exemple #8
0
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     if (_isDisposed)
     {
         return;
     }
     Pack("Timer", name, unit, tags, new[] {
         new JsonProperty("Total-Count", value.Rate.Count),
         new JsonProperty("Active-Sessions", value.ActiveSessions),
         new JsonProperty("Mean-Rate", value.Rate.MeanRate),
         new JsonProperty("1-Min-Rate", value.Rate.OneMinuteRate),
         new JsonProperty("5-Min-Rate", value.Rate.FiveMinuteRate),
         new JsonProperty("15-Min-Rate", value.Rate.FifteenMinuteRate),
         new JsonProperty("Last", value.Histogram.LastValue),
         new JsonProperty("Last-User-Value", value.Histogram.LastUserValue),
         new JsonProperty("Min", value.Histogram.Min),
         new JsonProperty("Min-User-Value", value.Histogram.MinUserValue),
         new JsonProperty("Mean", value.Histogram.Mean),
         new JsonProperty("Max", value.Histogram.Max),
         new JsonProperty("Max-User-Value", value.Histogram.MaxUserValue),
         new JsonProperty("StdDev", value.Histogram.StdDev),
         new JsonProperty("Median", value.Histogram.Median),
         new JsonProperty("Percentile-75", value.Histogram.Percentile75),
         new JsonProperty("Percentile-95", value.Histogram.Percentile95),
         new JsonProperty("Percentile-98", value.Histogram.Percentile98),
         new JsonProperty("Percentile-99", value.Histogram.Percentile99),
         new JsonProperty("Percentile-99_9", value.Histogram.Percentile999),
         new JsonProperty("Sample-Size", value.Histogram.SampleSize)
     });
 }
Exemple #9
0
        private void WriteLongMetricSummary(string type, string name, TimerValue value, MetricTags tags)
        {
            var n = name.ToLower(CultureInfo.InvariantCulture);

            // Help line
            _reportText.Append("# HELP ");
            _reportText.Append(n);
            _reportText.Append(" A summary of the ");
            _reportText.Append(n);
            _reportText.Append(" duration in millisecond ");
            _reportText.Append("\n");

            // Type line
            WriteTypeLineMetric(n, type);

            // Actual metric line

            _reportText.Append(n + "{quantile=\"0.75\"," + AddTags(tags, false) + "} " + FormatDouble(value.Histogram.Percentile75));
            _reportText.Append("\n");
            _reportText.Append(n + "{quantile=\"0.95\"," + AddTags(tags, false) + "} " + FormatDouble(value.Histogram.Percentile95));
            _reportText.Append("\n");
            _reportText.Append(n + "{quantile=\"0.98\"," + AddTags(tags, false) + "} " + FormatDouble(value.Histogram.Percentile98));
            _reportText.Append("\n");
            _reportText.Append(n + "{quantile=\"0.99\"," + AddTags(tags, false) + "} " + FormatDouble(value.Histogram.Percentile99));
            _reportText.Append("\n");
            _reportText.Append(n + "{quantile=\"0.999\"," + AddTags(tags, false) + "} " + FormatDouble(value.Histogram.Percentile999));
            _reportText.Append("\n");
            _reportText.Append(n + "_median" + AddTags(tags) + " " + FormatDouble(value.Histogram.Median));
            _reportText.Append("\n");
            _reportText.Append(n + "_sum" + AddTags(tags) + " " + FormatLong(value.TotalTime));
            _reportText.Append("\n");
            _reportText.Append(n + "_count" + AddTags(tags) + " " + FormatLong(value.Histogram.Count));
            _reportText.Append("\n\n"); // Extra end-of-line
        }
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     this.WriteMetricName(name);
     this.WriteValue("Active Sessions", value.ActiveSessions.ToString());
     this.WriteMeter(value.Rate, unit, rateUnit);
     this.WriteHistogram(value.Histogram, unit, durationUnit);
 }
Exemple #11
0
 public TimerReportItem(ServiceDescriptor service, string name, TimerValue timerValue) : base(service, name)
 {
     Value     = timerValue.ActiveSessions;
     Total     = new TimerTotals(timerValue.TotalTime, timerValue.Rate.Count);
     Rate      = new TimerRate(timerValue.Rate);
     Histogram = new TimerHistogram(timerValue.Histogram);
 }
Exemple #12
0
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit)
        {
            var values = MeterValues(value.Rate.Scale(rateUnit), unit, rateUnit)
                         .Concat(HistogramValues(value.Histogram.Scale(durationUnit), unit, durationUnit));

            Write("Timer", name, values);
        }
Exemple #13
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);
        }
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     Pack("Timer", name, unit, tags, new[] {
         new JsonProperty("Total Count", value.Rate.Count),
         new JsonProperty("Active Sessions", value.ActiveSessions),
         new JsonProperty("Mean Rate", value.Rate.MeanRate),
         new JsonProperty("1 Min Rate", value.Rate.OneMinuteRate),
         new JsonProperty("5 Min Rate", value.Rate.FiveMinuteRate),
         new JsonProperty("15 Min Rate", value.Rate.FifteenMinuteRate),
         new JsonProperty("Last", value.Histogram.LastValue),
         new JsonProperty("Last User Value", value.Histogram.LastUserValue),
         new JsonProperty("Min", value.Histogram.Min),
         new JsonProperty("Min User Value", value.Histogram.MinUserValue),
         new JsonProperty("Mean", value.Histogram.Mean),
         new JsonProperty("Max", value.Histogram.Max),
         new JsonProperty("Max User Value", value.Histogram.MaxUserValue),
         new JsonProperty("StdDev", value.Histogram.StdDev),
         new JsonProperty("Median", value.Histogram.Median),
         new JsonProperty("Percentile 75%", value.Histogram.Percentile75),
         new JsonProperty("Percentile 95%", value.Histogram.Percentile95),
         new JsonProperty("Percentile 98%", value.Histogram.Percentile98),
         new JsonProperty("Percentile 99%", value.Histogram.Percentile99),
         new JsonProperty(AdjustDottedFieldNames("Percentile 99.9%"), value.Histogram.Percentile999),
         new JsonProperty("Sample Size", value.Histogram.SampleSize)
     });
 }
Exemple #15
0
        // コンストラクタ
        public TimerControl()
        {
            // デフォルトの値をセット
            const int _defaultMinuteTimer = 0;
            const int _defaultSecondTimer = 0;

            TimerMinuteAndSecond = new TimerValue(_defaultMinuteTimer, _defaultSecondTimer);
        }
Exemple #16
0
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit)
        {
            var values = MeterValues(value.Rate, unit, rateUnit)
                         .Concat(HistogramValues(value.Histogram, unit, durationUnit))
                         .Concat(new[] { new Value("Active Sessions", value.ActiveSessions) });

            Write("Timer", name, values);
        }
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     TickCount++;
     TimerValue = TimerValue.Add(-MyDispatcherTimer.Interval);
     Tick();
     IfTimeZeroThenStop();
     CheckIfTimeIsEndingAlert();
 }
Exemple #18
0
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
        {
            var values = MeterValues(value.Rate, unit, rateUnit)
                .Concat(HistogramValues(value.Histogram, unit, durationUnit))
                .Concat(new[] { new Value("Active Sessions", value.ActiveSessions) });

            Write("Timer", name, values);
        }
Exemple #19
0
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
        {
            long count = value.Rate.Count;

            if (name.Contains(TaggedMetricsRegistry.INCREMENTAL_PREFIX))
            {
                string taggedName  = "timer:" + TaggedMetricsRegistry.TagName(name, tags);
                var    reportCount = count;
                if (incrementalMetrics.ContainsKey(taggedName))
                {
                    reportCount = count - incrementalMetrics[taggedName];
                }
                incrementalMetrics[taggedName] = count;
                name = name.Remove(name.IndexOf(TaggedMetricsRegistry.INCREMENTAL_PREFIX), TaggedMetricsRegistry.INCREMENTAL_PREFIX.Length);
                AddCounter(SubfolderName(name, unit, "Count"), reportCount, tags, MetricDetails.count);
                AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-Mean"), value.Histogram.Mean, tags, MetricDetails.mean);
                return;
            }

            if (name.Contains(TaggedMetricsRegistry.REPORT_ON_UPDATE_PREFIX))
            {
                string taggedName = "timer:" + 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, "Active_Sessions"), value.ActiveSessions, tags, MetricDetails.active_sessions);

            AddGauge(SubfolderName(name, AsRate(unit, rateUnit), "Rate-Mean"), value.Rate.MeanRate, tags, MetricDetails.rate_mean);
            AddGauge(SubfolderName(name, AsRate(unit, rateUnit), "Rate-1-min"), value.Rate.OneMinuteRate, tags, MetricDetails.rate_1min);
            AddGauge(SubfolderName(name, AsRate(unit, rateUnit), "Rate-5-min"), value.Rate.FiveMinuteRate, tags, MetricDetails.rate_5min);
            AddGauge(SubfolderName(name, AsRate(unit, rateUnit), "Rate-15-min"), value.Rate.FifteenMinuteRate, tags, MetricDetails.rate_15min);

            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-Last"), value.Histogram.LastValue, tags, MetricDetails.last);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-Min"), value.Histogram.Min, tags, MetricDetails.min);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-Mean"), value.Histogram.Mean, tags, MetricDetails.mean);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-Max"), value.Histogram.Max, tags, MetricDetails.max);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-StdDev"), value.Histogram.StdDev, tags, MetricDetails.stddev);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-Median"), value.Histogram.Median, tags, MetricDetails.median);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-p75"), value.Histogram.Percentile75, tags, MetricDetails.percent_75);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-p95"), value.Histogram.Percentile95, tags, MetricDetails.percent_95);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-p98"), value.Histogram.Percentile98, tags, MetricDetails.percent_98);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-p99"), value.Histogram.Percentile99, tags, MetricDetails.percent_99);
            AddGauge(SubfolderName(name, durationUnit.Unit(), "Duration-p999"), value.Histogram.Percentile999, tags, MetricDetails.percent_999);
        }
        public JsonSerializationTests()
        {
            this.timerValue = new TimerValue(this.meterValue, this.histogramValue, 0, 1, TimeUnit.Nanoseconds);

            this.counter   = new CounterValueSource("test1", Provider(counterValue), Unit.Errors, MetricTags.None);
            this.meter     = new MeterValueSource("test2", Provider(meterValue), Unit.Calls, TimeUnit.Seconds, MetricTags.None);
            this.histogram = new HistogramValueSource("test3", Provider(histogramValue), Unit.Items, MetricTags.None);
            this.timer     = new TimerValueSource("test4", Provider(timerValue), Unit.Requests, TimeUnit.Seconds, TimeUnit.Milliseconds, MetricTags.None);

            this.data = new MetricsData("test", new DateTime(2014, 2, 17), new[] { new EnvironmentEntry("name", "1") },
                                        new[] { gauge }, new[] { counter }, new[] { meter }, new[] { histogram }, new[] { timer },
                                        Enumerable.Empty <MetricsData>()
                                        );
            this.jsonContext = JsonMetricsContext.FromContext(this.data, "1");
        }
Exemple #21
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));
        }
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
        {
            Send(SubfolderName(name, unit, "Count"), value.Rate.Count);
            Send(SubfolderName(name, unit, "Active_Sessions"), value.ActiveSessions);

            Send(SubfolderName(name, AsRate(unit, rateUnit), "Rate-Mean"), value.Rate.MeanRate);
            Send(SubfolderName(name, AsRate(unit, rateUnit), "Rate-1-min"), value.Rate.OneMinuteRate);
            Send(SubfolderName(name, AsRate(unit, rateUnit), "Rate-5-min"), value.Rate.FiveMinuteRate);
            Send(SubfolderName(name, AsRate(unit, rateUnit), "Rate-15-min"), value.Rate.FifteenMinuteRate);

            Send(SubfolderName(name, durationUnit.Unit(), "Duration-Last"), value.Histogram.LastValue);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-Min"), value.Histogram.Min);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-Mean"), value.Histogram.Mean);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-Max"), value.Histogram.Max);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-StdDev"), value.Histogram.StdDev);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-Median"), value.Histogram.Median);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-p75"), value.Histogram.Percentile75);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-p95"), value.Histogram.Percentile95);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-p98"), value.Histogram.Percentile98);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-p99"), value.Histogram.Percentile99);
            Send(SubfolderName(name, durationUnit.Unit(), "Duration-p999"), value.Histogram.Percentile999);
        }
Exemple #23
0
        protected void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
        {
            var te = Pack("Timer", name, unit, tags, new JObject {
                { "totalCount", value.Rate.Count },
                { "activeSessions", value.ActiveSessions },
                { "meanRate", _resetOnReport ? ((double)value.Rate.Count / _reportingPeriodSec) : value.Rate.MeanRate },
                { "1MinRate", value.Rate.OneMinuteRate },
                { "5MinRate", value.Rate.FiveMinuteRate },
                { "last", value.Histogram.LastValue },
                { "min", value.Histogram.Min },
                { "mean", value.Histogram.Mean },
                { "max", value.Histogram.Max },
                { "stdDev", value.Histogram.StdDev },
                { "median", value.Histogram.Median },
                { "percentile75", value.Histogram.Percentile75 },
                { "percentile95", value.Histogram.Percentile95 },
                { "percentile99", value.Histogram.Percentile99 },
                { "sampleSize", value.Histogram.SampleSize }
            });

            _subject.OnNext(te);
        }
Exemple #24
0
        public void reportTimer_simpleTimer_addedAllStats()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");
            TimerValue timer = this.timer(meter(1000, 1.0, 60.0, 300.0, 900.0),
                                          histogram(1000, 1.0, "", 2.0, "", 1.1, 0.1, "", 0.2, 1.1, 1.3, 1.8, 1.9, 2.0, 2.0),
                                          5,
                                          1100);

            // Act
            telegrafReport.call("ReportTimer", "testtimer", timer, Unit.Items, TimeUnit.Seconds, TimeUnit.Seconds, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(19, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testtimer.rate.count", 1000L, "")));
            Assert.IsTrue(PointsEqual(points[1], GetDataPoint("testtimer.rate.avg", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[2], GetDataPoint("testtimer.rate.1m", 60.0, "")));
            Assert.IsTrue(PointsEqual(points[3], GetDataPoint("testtimer.rate.5m", 300.0, "")));
            Assert.IsTrue(PointsEqual(points[4], GetDataPoint("testtimer.rate.15m", 900.0, "")));
            Assert.IsTrue(PointsEqual(points[5], GetDataPoint("testtimer.count", 1000L, "")));
            Assert.IsTrue(PointsEqual(points[6], GetDataPoint("testtimer.last", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[7], GetDataPoint("testtimer.min", 0.1, "")));
            Assert.IsTrue(PointsEqual(points[8], GetDataPoint("testtimer.avg", 1.1, "")));
            Assert.IsTrue(PointsEqual(points[9], GetDataPoint("testtimer.max", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[10], GetDataPoint("testtimer.stdDev", 0.2, "")));
            Assert.IsTrue(PointsEqual(points[11], GetDataPoint("testtimer.median", 1.1, "")));
            Assert.IsTrue(PointsEqual(points[12], GetDataPoint("testtimer.75percentile", 1.3, "")));
            Assert.IsTrue(PointsEqual(points[13], GetDataPoint("testtimer.95percentile", 1.8, "")));
            Assert.IsTrue(PointsEqual(points[14], GetDataPoint("testtimer.98percentile", 1.9, "")));
            Assert.IsTrue(PointsEqual(points[15], GetDataPoint("testtimer.99percentile", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[16], GetDataPoint("testtimer.999percentile", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[17], GetDataPoint("testtimer.sessions", 5L, "")));
            Assert.IsTrue(PointsEqual(points[18], GetDataPoint("testtimer.total", 1100L, "")));
        }
Exemple #25
0
        /// <summary>
        /// Report Timers as a single metric for the time, plus individual rate and duration metrics
        /// in case the Ops team wants to report or alert on specific subvalues.
        /// </summary>
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
        {
            if (tags.Tags.Contains(DoNotReport))
            {
                return;
            }

            var props = new Dictionary <string, string>();

            props["Unit"]         = unit.Name;
            props["DurationUnit"] = Enum.GetName(typeof(TimeUnit), durationUnit);;
            if (tags.Tags != null && tags.Tags.Length > 0)
            {
                props["Tags"] = String.Join(",", tags.Tags);
            }

            props["Name"]  = name + " {Mean}";
            props["Value"] = unit.FormatDuration(value.Histogram.Mean, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Mean, props);

            props["Name"]  = name + " {Median}";
            props["Value"] = unit.FormatDuration(value.Histogram.Median, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Median, props);

            props["Name"]  = name + " {Percentile75}";
            props["Value"] = unit.FormatDuration(value.Histogram.Percentile75, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Percentile75, props);

            props["Name"]  = name + " {Percentile95}";
            props["Value"] = unit.FormatDuration(value.Histogram.Percentile95, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Percentile95, props);

            props["Name"]  = name + " {Percentile98}";
            props["Value"] = unit.FormatDuration(value.Histogram.Percentile98, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Percentile98, props);

            props["Name"]  = name + " {Percentile99}";
            props["Value"] = unit.FormatDuration(value.Histogram.Percentile99, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Percentile99, props);

            props["Name"]  = name + " {Percentile999}";
            props["Value"] = unit.FormatDuration(value.Histogram.Percentile999, durationUnit);
            Client.TrackMetric(props["Name"], value.Histogram.Percentile999, props);

            props["RateUnit"] = Enum.GetName(typeof(TimeUnit), rateUnit);;
            props.Remove("DurationUnit");

            props["Name"]  = name + " {MeanRate}";
            props["Value"] = unit.FormatRate(value.Rate.MeanRate, rateUnit);
            Client.TrackMetric(props["Name"], value.Rate.MeanRate, props);

            props["Name"]  = name + " {OneMinuteRate}";
            props["Value"] = unit.FormatRate(value.Rate.OneMinuteRate, rateUnit);
            Client.TrackMetric(props["Name"], value.Rate.OneMinuteRate, props);

            props["Name"]  = name + " {FiveMinuteRate}";
            props["Value"] = unit.FormatRate(value.Rate.FiveMinuteRate, rateUnit);
            Client.TrackMetric(props["Name"], value.Rate.FiveMinuteRate, props);

            props["Name"]  = name + " {FifteenMinuteRate}";
            props["Value"] = unit.FormatRate(value.Rate.FifteenMinuteRate, rateUnit);
            Client.TrackMetric(props["Name"], value.Rate.FifteenMinuteRate, props);


            // Timer has both meter and histogram data
            var telm = new MetricTelemetry(name, (int)value.Histogram.Count, value.TotalTime,
                                           value.Histogram.Min, value.Histogram.Max, value.Histogram.StdDev);

            telm.Properties["Name"]         = name;
            telm.Properties["Value"]        = unit.FormatDuration(value.TotalTime, durationUnit);
            telm.Properties["Unit"]         = unit.Name;
            telm.Properties["RateUnit"]     = Enum.GetName(typeof(TimeUnit), rateUnit);
            telm.Properties["DurationUnit"] = Enum.GetName(typeof(TimeUnit), durationUnit);
            if (tags.Tags != null && tags.Tags.Length > 0)
            {
                telm.Properties["Tags"] = String.Join(",", tags.Tags);
            }

            telm.Properties["MeanRate"]          = unit.FormatRate(value.Rate.MeanRate, rateUnit);
            telm.Properties["OneMinuteRate"]     = unit.FormatRate(value.Rate.OneMinuteRate, rateUnit);
            telm.Properties["FiveMinuteRate"]    = unit.FormatRate(value.Rate.FiveMinuteRate, rateUnit);
            telm.Properties["FifteenMinuteRate"] = unit.FormatRate(value.Rate.FifteenMinuteRate, rateUnit);

            telm.Properties["Mean"]          = unit.FormatDuration(value.Histogram.Mean, durationUnit);
            telm.Properties["Median"]        = unit.FormatDuration(value.Histogram.Median, durationUnit);
            telm.Properties["Percentile75"]  = unit.FormatDuration(value.Histogram.Percentile75, durationUnit);
            telm.Properties["Percentile95"]  = unit.FormatDuration(value.Histogram.Percentile95, durationUnit);
            telm.Properties["Percentile98"]  = unit.FormatDuration(value.Histogram.Percentile98, durationUnit);
            telm.Properties["Percentile99"]  = unit.FormatDuration(value.Histogram.Percentile99, durationUnit);
            telm.Properties["Percentile999"] = unit.FormatDuration(value.Histogram.Percentile999, durationUnit);

            Client.TrackMetric(telm);
        }
        /// <summary>
        /// Creates new <see cref="InfluxRecord"/> instances for the timer values and any items in the meter item sets.
        /// </summary>
        /// <param name="name">The measurement name.</param>
        /// <param name="tags">Any additional tags to add to the <see cref="InfluxRecord"/>, these tags overwrite any global tags with the same name.</param>
        /// <param name="unit">The metric unit.</param>
        /// <param name="value">The metric value object.</param>
        /// <returns>A list of <see cref="InfluxRecord"/> instances for the specified metric value.</returns>
        public IEnumerable <InfluxRecord> GetRecords(String name, MetricTags tags, Unit unit, TimerValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            yield return(GetRecord(name, tags, new[] {
                new InfluxField("Active Sessions", value.ActiveSessions),
                new InfluxField("Total Time", value.TotalTime),
                new InfluxField("Count", value.Rate.Count),
                new InfluxField("Mean Rate", value.Rate.MeanRate),
                new InfluxField("1 Min Rate", value.Rate.OneMinuteRate),
                new InfluxField("5 Min Rate", value.Rate.FiveMinuteRate),
                new InfluxField("15 Min Rate", value.Rate.FifteenMinuteRate),
                new InfluxField("Last", value.Histogram.LastValue),
                new InfluxField("Min", value.Histogram.Min),
                new InfluxField("Mean", value.Histogram.Mean),
                new InfluxField("Max", value.Histogram.Max),
                new InfluxField("StdDev", value.Histogram.StdDev),
                new InfluxField("Median", value.Histogram.Median),
                new InfluxField("Sample Size", value.Histogram.SampleSize),
                new InfluxField("Percentile 75%", value.Histogram.Percentile75),
                new InfluxField("Percentile 95%", value.Histogram.Percentile95),
                new InfluxField("Percentile 98%", value.Histogram.Percentile98),
                new InfluxField("Percentile 99%", value.Histogram.Percentile99),
                new InfluxField("Percentile 99.9%", value.Histogram.Percentile999),

                // ignored histogram values
                //new InfluxField("Last User Value",  value.Histogram.LastUserValue),
                //new InfluxField("Min User Value",   value.Histogram.MinUserValue),
                //new InfluxField("Max User Value",   value.Histogram.MaxUserValue),
            }));

            // NOTE: I'm not sure if this is needed, it appears the timer only adds set item values
            // to the histogram and not to the meter. I'm not sure if this is a bug or by design.
            foreach (var i in value.Rate.Items)
            {
                yield return(GetRecord(name, i.Item, tags, new[] {
                    new InfluxField("Count", i.Value.Count),
                    new InfluxField("Percent", i.Percent),
                    new InfluxField("Mean Rate", i.Value.MeanRate),
                    new InfluxField("1 Min Rate", i.Value.OneMinuteRate),
                    new InfluxField("5 Min Rate", i.Value.FiveMinuteRate),
                    new InfluxField("15 Min Rate", i.Value.FifteenMinuteRate),
                }));
            }
        }
Exemple #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="unit"></param>
 /// <param name="rateUnit"></param>
 /// <param name="durationUnit"></param>
 /// <param name="tags"></param>
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit,
                                     TimeUnit durationUnit, MetricTags tags)
 {
     // The semantics between prometheus and Metrics.NET are different enough that we just want to pass a gauge
     WriteLongMetricSummary("summary", name, value, tags);
 }
Exemple #28
0
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     m_items.Add(new TimerReportItem(m_service, name, value));
 }
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
   this.metricName = name;
   base.ReportTimer(name, value, unit, rateUnit, durationUnit, tags);
 }
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit)
 {
     this.WriteMetricName(name);
     this.WriteMeter(value.Rate.Scale(rateUnit), unit, rateUnit);
     this.WriteHistogram(value.Histogram.Scale(durationUnit), unit, durationUnit);
 }
Exemple #31
0
 protected abstract void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags);
Exemple #32
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);
        }
Exemple #33
0
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit)
 {
     this.WriteMetricName(name);
     this.WriteMeter(value.Rate.Scale(rateUnit), unit, rateUnit);
     this.WriteHistogram(value.Histogram.Scale(durationUnit), unit, durationUnit);
 }
Exemple #34
0
 public AppMetricsTimerValue(TimerValue value)
 {
     Histogram    = new AppMetricsHistogramValue(value.Histogram);
     Rate         = new AppMetricsMeterValue(value.Rate);
     DurationUnit = value.DurationUnit;
 }
 ///<inheritdoc/>
 protected override void ReportTimer(String name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     writer.Write(converter.GetRecords(name, tags, unit, value).Select(r => formatter?.FormatRecord(r) ?? r));
 }
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     Pack("Timer", name, unit, tags, new[] { 
         new JsonProperty("Total Count",value.Rate.Count),
         new JsonProperty("Active Sessions",value.ActiveSessions),
         new JsonProperty("Mean Rate", value.Rate.MeanRate),
         new JsonProperty("1 Min Rate", value.Rate.OneMinuteRate),
         new JsonProperty("5 Min Rate", value.Rate.FiveMinuteRate),
         new JsonProperty("15 Min Rate", value.Rate.FifteenMinuteRate),
         new JsonProperty("Last", value.Histogram.LastValue),
         new JsonProperty("Last User Value", value.Histogram.LastUserValue),
         new JsonProperty("Min",value.Histogram.Min),
         new JsonProperty("Min User Value",value.Histogram.MinUserValue),
         new JsonProperty("Mean",value.Histogram.Mean),
         new JsonProperty("Max",value.Histogram.Max),
         new JsonProperty("Max User Value",value.Histogram.MaxUserValue),
         new JsonProperty("StdDev",value.Histogram.StdDev),
         new JsonProperty("Median",value.Histogram.Median),
         new JsonProperty("Percentile 75%",value.Histogram.Percentile75),
         new JsonProperty("Percentile 95%",value.Histogram.Percentile95),
         new JsonProperty("Percentile 98%",value.Histogram.Percentile98),
         new JsonProperty("Percentile 99%",value.Histogram.Percentile99),
         new JsonProperty("Percentile 99.9%" ,value.Histogram.Percentile999),
         new JsonProperty("Sample Size", value.Histogram.SampleSize)
     });
 }
Exemple #37
0
 protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
 {
     this.metricName = name;
     base.ReportTimer(name, value, unit, rateUnit, durationUnit, tags);
 }