private void LogHistogram(IRequest request, MetricName metricName, HistogramMetric metric, long timestamp) { LogGauge(request, metricName.Name + "." + HistogramMetrics.Max.GetDatadogName(), metric.SampleMax, timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.Min.GetDatadogName(), metric.SampleMin, timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.Mean.GetDatadogName(), metric.SampleMean, timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.StdDev.GetDatadogName(), metric.StdDev, timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.Count.GetDatadogName(), metric.SampleCount, timestamp); double[] percentResults = metric.Percentiles(_histogramPercentages); LogGauge(request, metricName.Name + "." + HistogramMetrics.At75thPercentile.GetDatadogName(), percentResults[0], timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.At95thPercentile.GetDatadogName(), percentResults[1], timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.At98thPercentile.GetDatadogName(), percentResults[2], timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.At99thPercentile.GetDatadogName(), percentResults[3], timestamp); LogGauge(request, metricName.Name + "." + HistogramMetrics.At999thPercentile.GetDatadogName(), percentResults[4], timestamp); metric.Clear(); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void SendData(object pState) { foreach (string path in vTimerPaths) { ManualTimerMetric mtm = Metrics.ManualTimer(GetType(), path, TimeUnit.Milliseconds, TimeUnit.Milliseconds); double[] perc = mtm.Percentiles(0.95, 0.99); vGraphite.Send(path + ".timer.mean", mtm.Mean); vGraphite.Send(path + ".timer.p95", perc[0]); vGraphite.Send(path + ".timer.p99", perc[1]); mtm.Clear(); } foreach (string path in vMeanPaths) { HistogramMetric hm = Metrics.Histogram(GetType(), path); vGraphite.Send(path + ".mean", hm.Mean); hm.Clear(); } foreach (string path in vCounterPaths) { CounterMetric cm = Metrics.Counter(GetType(), path); vGraphite.Send(path + ".counter", cm.Count); cm.Clear(); } foreach (string path in vGaugePaths) { GaugeMetric <long> gm = Metrics.Gauge <long>(GetType(), path, null); vGraphite.Send(path + ".gauge", gm.Value); } ResetPaths(); }