public static IEnumerable <Metric> ToPrometheusMetrics(this HistogramValueSource metric) { var result = new List <Metric> { new Metric { summary = new Summary { sample_count = (ulong)metric.Value.Count, sample_sum = metric.Value.Sum, quantile = { new Quantile { quantile = 0.5, value = metric.Value.Mean }, new Quantile { quantile = 0.75, value = metric.Value.Percentile75 }, new Quantile { quantile = 0.95, value = metric.Value.Percentile95 }, // new Quantile(){quantile = 0.98, value = metric.Value.Percentile98}, new Quantile { quantile = 0.99, value = metric.Value.Percentile99 }, // new Quantile(){quantile = 0.999, value = metric.Value.Percentile999} } }, label = metric.Tags.ToLabelPairs() } }; return(result); }
private static MetricTelemetry Translate(HistogramValueSource source, string contextName, DateTimeOffset now) { var mt = MetricFactory.CreateMetric(source, contextName, now); source.Value.CopyTo(mt); return(mt); }
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 }); }
public HistogramSerializationTests(ITestOutputHelper output, MetricProviderTestFixture fixture) { _output = output; _serializer = new MetricDataSerializer(); _histogram = fixture.Histograms.First(x => x.Name == fixture.HistogramNameDefault); _histogramWithGroup = fixture.Histograms.First(x => x.Name == fixture.HistogramNameWithGroup); }
public static Histogram ToMetric(this HistogramValueSource source) { return(new Histogram { Name = source.Name, Count = source.Value.Count, Unit = source.Unit.Name, LastUserValue = source.Value.LastUserValue, LastValue = source.Value.LastValue, Max = source.Value.Max, MaxUserValue = source.Value.MaxUserValue, Mean = source.Value.Mean, Median = source.Value.Median, Min = source.Value.Min, MinUserValue = source.Value.MinUserValue, Percentile75 = source.Value.Percentile75, Percentile95 = source.Value.Percentile95, Percentile98 = source.Value.Percentile98, Percentile99 = source.Value.Percentile99, Percentile999 = source.Value.Percentile999, SampleSize = source.Value.SampleSize, StdDev = source.Value.StdDev, Tags = source.Tags }); }
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); }
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"); }
public static JsonHistogram FromHistogram(HistogramValueSource histogram) { return(new JsonHistogram { Name = histogram.Name, Count = histogram.Value.Count, LastValue = histogram.Value.LastValue, LastUserValue = histogram.Value.LastUserValue, Max = histogram.Value.Max, MaxUserValue = histogram.Value.MaxUserValue, Mean = histogram.Value.Mean, Min = histogram.Value.Min, MinUserValue = histogram.Value.MinUserValue, StdDev = histogram.Value.StdDev, Median = histogram.Value.Median, Percentile75 = histogram.Value.Percentile75, Percentile95 = histogram.Value.Percentile95, Percentile98 = histogram.Value.Percentile98, Percentile99 = histogram.Value.Percentile99, Percentile999 = histogram.Value.Percentile999, SampleSize = histogram.Value.SampleSize, Unit = histogram.Unit.Name, Tags = histogram.Tags, Sum = histogram.Value.Sum }); }
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 }); }
public static IEnumerable <MetricsValue> ToPrometheusMetrics(this HistogramValueSource metric) { var result = new List <MetricsValue> { new MetricsValue { Summary = new Summary { Sample_Count = (ulong)metric.Value.Count, Sample_Sum = metric.Value.Sum, Quantile = { new Quantile { QuantileValue = 0.5, Value = metric.Value.Median }, new Quantile { QuantileValue = 0.75, Value = metric.Value.Percentile75 }, new Quantile { QuantileValue = 0.95, Value = metric.Value.Percentile95 }, new Quantile { QuantileValue = 0.99, Value = metric.Value.Percentile99 } } }, Label = metric.Tags.ToLabelPairs() } }; return(result); }
private MetricsContextValueSource CreateValueSource( string context, GaugeValueSource gauges = null, CounterValueSource counters = null, MeterValueSource meters = null, HistogramValueSource histograms = null, BucketHistogramValueSource bucketHistograms = null, TimerValueSource timers = null, BucketTimerValueSource bucketTimers = null, ApdexValueSource apdexScores = null) { var gaugeValues = gauges != null ? new[] { gauges } : Enumerable.Empty <GaugeValueSource>(); var counterValues = counters != null ? new[] { counters } : Enumerable.Empty <CounterValueSource>(); var meterValues = meters != null ? new[] { meters } : Enumerable.Empty <MeterValueSource>(); var histogramValues = histograms != null ? new[] { histograms } : Enumerable.Empty <HistogramValueSource>(); var bucketHistogramValues = bucketHistograms != null ? new[] { bucketHistograms } : Enumerable.Empty <BucketHistogramValueSource>(); var timerValues = timers != null ? new[] { timers } : Enumerable.Empty <TimerValueSource>(); var bucketTimerValues = bucketTimers != null ? new[] { bucketTimers } : Enumerable.Empty <BucketTimerValueSource>(); var apdexScoreValues = apdexScores != null ? new[] { apdexScores } : Enumerable.Empty <ApdexValueSource>(); return(new MetricsContextValueSource( context, gaugeValues, counterValues, meterValues, histogramValues, bucketHistogramValues, timerValues, bucketTimerValues, apdexScoreValues)); }
/// <summary> /// Determines whether the specified histogram is match. /// </summary> /// <param name="histogram">The histogram.</param> /// <returns></returns> public bool IsMatch(HistogramValueSource histogram) { if (_types != null && !_types.Contains(MetricType.Histogram)) { return(false); } return(IsMetricNameMatch(histogram.Name) && IsTagMatch(histogram.Tags)); }
private static MetricTelemetry TranslateHistogramSource(HistogramValueSource source, string contextName, DateTimeOffset now) { var mt = MetricFactory.CreateMetric(source, contextName, now); TranslateTags(source.Tags, mt); TranslateHistogram(source.Value, mt, Constants.HistogramTypeValue); return(mt); }
public IHistogram Histogram <T>(HistogramOptions options, Func <T> builder) where T : IHistogramMetric { return(_histograms.GetOrAdd(options.Name, () => { var histogram = builder(); var valueSource = new HistogramValueSource(options.Name, histogram, options.MeasurementUnit, AllTags(options.Tags)); return Tuple.Create((IHistogram)histogram, valueSource); })); }
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); }
private static IEnumerable <JsonProperty> ToJsonProperties(HistogramValueSource histogram) { yield return(new JsonProperty("Name", histogram.Name)); foreach (var property in ToJsonProperties(histogram.Value)) { yield return(property); } yield return(new JsonProperty("Unit", histogram.Unit.Name)); }
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"); }
private static MetricDatum Translate(HistogramValueSource source, string contextName, DateTimeOffset now) { var mt = new MetricDatum { MetricName = contextName, TimestampUtc = now.UtcDateTime, StatisticValues = new StatisticSet { Maximum = source.Value.Max, Minimum = source.Value.Min, SampleCount = source.Value.Count, Sum = source.Value.Sum } }; return(mt); }
public async Task Can_report_histograms_when_multidimensional() { // Arrange var expected = "test.test_histogram.histogram.value:1000|h"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram" + MultidimensionalMetricNameSuffix, ConstantValue.Provider(histogram.Value), Unit.None, _tags); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public void can_report_histograms() { var metricsMock = new Mock <IMetrics>(); var histogram = new HistogramMetric(SamplingType.ExponentiallyDecaying, 1028, 0.015); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource("test histogram", ConstantValue.Provider(histogram.Value), Unit.None, MetricTags.None); var payloadBuilder = new LineProtocolPayloadBuilder(); var reporter = CreateReporter(payloadBuilder); reporter.StartReportRun(metricsMock.Object); reporter.ReportMetric("test", histogramValueSource); payloadBuilder.PayloadFormatted() .Should() .Be( "test__test_histogram samples=1i,last=1000,count.hist=1i,min=1000,max=1000,mean=1000,median=1000,stddev=0,p999=1000,p99=1000,p98=1000,p95=1000,p75=1000,user.last=\"client1\",user.min=\"client1\",user.max=\"client1\"\n"); }
public async Task Can_report_histograms_when_multidimensional() { // Arrange var expected = "{\"series\":[{\"metric\":\"test.test_histogram.histogram.samples\",\"points\":[[1483232461,1]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.last\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.count.hist\",\"points\":[[1483232461,1]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.sum\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.min\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.max\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.mean\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.median\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.stddev\",\"points\":[[1483232461,0]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.p999\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.p99\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.p98\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.p95\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.p75\",\"points\":[[1483232461,1000]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.user.last\",\"points\":[[1483232461,0]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.user.min\",\"points\":[[1483232461,0]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]},{\"metric\":\"test.test_histogram.histogram.user.max\",\"points\":[[1483232461,0]],\"type\":\"gauge\",\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\"]}]}"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram" + MultidimensionalMetricNameSuffix, ConstantValue.Provider(histogram.Value), Unit.None, _tags); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), FlushInterval, expected); }
public void Can_report_histograms_when_multidimensional() { // Arrange var expected = "env.staging.histogram.test.test_histogram.host.server1.Samples 1 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Last 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Count 1 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Sum 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Min 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Max 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Mean 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Median 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.StdDev 0.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Percentile-999 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Percentile-99 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Percentile-98 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Percentile-95 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.Percentile-75 1000.00 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.User-Last client1 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.User-Min client1 1483232461\nenv.staging.histogram.test.test_histogram.host.server1.User-Max client1 1483232461\n"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram" + MultidimensionalMetricNameSuffix, ConstantValue.Provider(histogram.Value), Unit.None, _tags); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public async Task Can_report_histograms() { // Arrange var expected = "test.test_histogram.histogram.value:1000|h|#unit:none,timestamp:1483232461"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram", ConstantValue.Provider(histogram.Value), Unit.None, MetricTags.Empty); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public async Task Can_report_histograms() { // Arrange var expected = "test__test_histogram,mtype=histogram,unit=none samples=1i,last=1000,count.hist=1i,sum=1000,min=1000,max=1000,mean=1000,median=1000,stddev=0,p999=1000,p99=1000,p98=1000,p95=1000,p75=1000,user.last=\"client1\",user.min=\"client1\",user.max=\"client1\" 1483232461000000000\n"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram", ConstantValue.Provider(histogram.Value), Unit.None, MetricTags.Empty); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public IHistogram Histogram <T>(HistogramOptions options, Func <T> builder) where T : IHistogramMetric { return(_histograms.GetOrAdd( options.Name, () => { var allTags = AllTags(options.Tags); Logger.Debug("Adding Histogram {Name} - {@Options} {MesurementUnit} {@Tags}", options.Name, options, options.MeasurementUnit.ToString(), allTags.ToDictionary()); var histogram = builder(); var valueSource = new HistogramValueSource( options.Name, histogram, options.MeasurementUnit, allTags); return Tuple.Create((IHistogram)histogram, valueSource); })); }
public void Can_report_histograms_when_multidimensional() { // Arrange var expected = "test__test_histogram,host=server1,env=staging,mtype=histogram,unit=none samples=1i,last=1000,count.hist=1i,sum=1000,min=1000,max=1000,mean=1000,median=1000,stddev=0,p999=1000,p99=1000,p98=1000,p95=1000,p75=1000,user.last=\"client1\",user.min=\"client1\",user.max=\"client1\" 1483232461000000000\n"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram" + MultidimensionalMetricNameSuffix, ConstantValue.Provider(histogram.Value), Unit.None, _tags); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public void Can_report_histograms() { // Arrange var expected = "histogram.test.test_histogram.Samples 1 1483232461\nhistogram.test.test_histogram.Last 1000.00 1483232461\nhistogram.test.test_histogram.Count 1 1483232461\nhistogram.test.test_histogram.Sum 1000.00 1483232461\nhistogram.test.test_histogram.Min 1000.00 1483232461\nhistogram.test.test_histogram.Max 1000.00 1483232461\nhistogram.test.test_histogram.Mean 1000.00 1483232461\nhistogram.test.test_histogram.Median 1000.00 1483232461\nhistogram.test.test_histogram.StdDev 0.00 1483232461\nhistogram.test.test_histogram.Percentile-999 1000.00 1483232461\nhistogram.test.test_histogram.Percentile-99 1000.00 1483232461\nhistogram.test.test_histogram.Percentile-98 1000.00 1483232461\nhistogram.test.test_histogram.Percentile-95 1000.00 1483232461\nhistogram.test.test_histogram.Percentile-75 1000.00 1483232461\nhistogram.test.test_histogram.User-Last client1 1483232461\nhistogram.test.test_histogram.User-Min client1 1483232461\nhistogram.test.test_histogram.User-Max client1 1483232461\n"; var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram", ConstantValue.Provider(histogram.Value), Unit.None, MetricTags.Empty); // Act var valueSource = CreateValueSource("test", histograms: histogramValueSource); // Assert AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public void can_report_histograms_when_multidimensional() { var metricsMock = new Mock <IMetrics>(); var histogram = new DefaultHistogramMetric(_defaultReservoir); histogram.Update(1000, "client1"); var histogramValueSource = new HistogramValueSource( "test histogram" + MultidimensionalMetricNameSuffix, ConstantValue.Provider(histogram.Value), Unit.None, _tags); var items = CreateReporterAndPayloadBuilder(); items.Item1.StartReportRun(metricsMock.Object); items.Item1.ReportMetric("test", histogramValueSource); items.Item2.PayloadFormatted(). Should(). Be( "test__test_histogram host=server1 env=staging mtype=histogram unit=none samples=1i last=1000 count.hist=1i sum=1000 min=1000 max=1000 mean=1000 median=1000 stddev=0 p999=1000 p99=1000 p98=1000 p95=1000 p75=1000 user.last=\"client1\" user.min=\"client1\" user.max=\"client1\"" + Environment.NewLine); }
public static IEnumerable <MetricValue> ToMackerelMetrics(this HistogramValueSource metric) { var result = new List <MetricValue> { new MetricValue { name = "Meta.Count", value = metric.Value.Count }, new MetricValue { name = "Meta.Sum", value = metric.Value.Sum.ToDecimal() }, new MetricValue { name = "Median", value = metric.Value.Median.ToDecimal() }, new MetricValue { name = "Percentile75", value = metric.Value.Percentile75.ToDecimal() }, new MetricValue { name = "Percentile95", value = metric.Value.Percentile95.ToDecimal() }, new MetricValue { name = "Percentile99", value = metric.Value.Percentile99.ToDecimal() }, }; // new Quantile(){quantile = 0.98, value = metric.Value.Percentile98}, // new Quantile(){quantile = 0.999, value = metric.Value.Percentile999} return(result); }
/// <inheritdoc /> public IHistogram Histogram <T>(HistogramOptions options, MetricTags tags, Func <T> builder) where T : IHistogramMetric { var allTags = AllTags(MetricTags.Concat(options.Tags, tags)); var metricName = allTags.AsMetricName(options.Name); return(_histograms.GetOrAdd( metricName, () => { Logger.Trace("Adding Histogram {Name} - {@Options} {MesurementUnit} {@Tags}", metricName, options, options.MeasurementUnit.ToString(), allTags.ToDictionary()); var histogram = builder(); var valueSource = new HistogramValueSource( metricName, histogram, options.MeasurementUnit, allTags, options.ResetOnReporting); return Tuple.Create((IHistogram)histogram, valueSource); })); }
public bool IsMatch(HistogramValueSource histogram) { if (types != null && !types.Contains(MetricType.Histogram)) { return false; } return IsNameMatch(histogram.Name); }
private static IEnumerable<Google.ICanReportToGoogleAnalytics> Map(HistogramValueSource histogram, string context) { return new Google.Histogram(FullName(histogram.Name, context), histogram.Unit.Name, histogram.Value.Count, histogram.Value.LastValue, histogram.Value.Max, histogram.Value.Min, histogram.Value.Mean, histogram.Value.StdDev, histogram.Value.Percentile75, histogram.Value.Percentile95, histogram.Value.Percentile98, histogram.Value.Percentile99, histogram.Value.Percentile999); }
public bool IsMatch(HistogramValueSource histogram) { return true; }