Ejemplo n.º 1
0
        public void Can_safely_remove_metrics_from_outer_collection_without_affecting_registry()
        {
            var name = new MetricName("MeterTests", "Can_safely_remove_metrics_from_outer_collection_without_affecting_registry");
            var meter = Metrics.Meter("MeterTests", "Can_safely_remove_metrics_from_outer_collection_without_affecting_registry", "test", TimeUnit.Seconds);
            meter.Mark(3);

            Metrics.All.Remove(name);
            var metric = Metrics.All[name];
            Assert.IsNotNull(metric, "Metric was removed from central registry");
        }
        public void Can_serialize_metrics_with_changes()
        {
            var name = new MetricName("MeterTests", "Can_serialize_metrics_with_changes");
            var meter = Metrics.Meter("MeterTests", "Can_serialize_metrics_with_changes", "test", TimeUnit.Seconds);
            Assert.IsNotNull(Metrics.All[name], "Metric not found in central registry");

            meter.Mark(3);

            var reporter = new JsonReportFormatter();
            var json = reporter.GetSample();
            Console.WriteLine(json);
        }
Ejemplo n.º 3
0
        public void Can_get_all_registered_metrics_as_readonly_and_immutable()
        {
            Assert.AreEqual(0, Metrics.All.Count);
            var name = new MetricName("CounterTests", "Can_get_all_registered_metrics_as_readonly_and_immutable");
            Metrics.Counter("CounterTests", "Can_get_all_registered_metrics_as_readonly_and_immutable");
            Assert.AreEqual(1, Metrics.All.Count);

            var value = Metrics.All[name];

            Assert.IsNotNull(value);
            ((CounterMetric) value).Increment();
            Assert.AreEqual(0, ((CounterMetric) Metrics.All[name]).Count);
        }
Ejemplo n.º 4
0
        public void Can_get_metrics_from_collection_with_registered_changes()
        {
            // Counter
            var name = new MetricName("MeterTests", "counter");
            var counter = Metrics.Counter("MeterTests", "counter");
            Assert.IsNotNull(Metrics.All[name], "Metric not found in central registry");
            counter.Increment(10);
            var actual = ((CounterMetric)Metrics.All[name]).Count;
            Assert.AreEqual(10, actual, "Immutable copy did not contain correct values for this metric");

            // Meter
            name = new MetricName("MeterTests", "meter");
            var meter = Metrics.Meter("MeterTests", "meter", "test", TimeUnit.Seconds);
            Assert.IsNotNull(Metrics.All[name], "Metric not found in central registry");
            meter.Mark(3);
            actual = ((MeterMetric)Metrics.All[name]).Count;
            Assert.AreEqual(3, actual, "Immutable copy did not contain correct values for this metric");
        }
Ejemplo n.º 5
0
 public bool Equals(MetricName other)
 {
     return Equals(other.Name, Name) && Equals(other.Class, Class);
 }
 private void LogTimer(IRequest request, MetricName metricName, TimerMetric metric, long timestamp)
 {
     LogGauge(request, metricName.Name + "." + TimerMetrics.FifteenMinuteRate.GetDatadogName(), metric.FifteenMinuteRate, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.FiveMinuteRate.GetDatadogName(), metric.FiveMinuteRate, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.OneMinuteRate.GetDatadogName(), metric.OneMinuteRate, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.Max.GetDatadogName(), metric.Max, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.Mean.GetDatadogName(), metric.Mean, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.MeanRate.GetDatadogName(), metric.MeanRate, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.Min.GetDatadogName(), metric.Min, timestamp);
     LogGauge(request, metricName.Name + "." + TimerMetrics.StdDev.GetDatadogName(), metric.StdDev, timestamp);
 }
 private void LogGauge(IRequest request, MetricName metricName, GaugeMetric metric, long timestamp)
 {
     LogGauge(request, metricName.Name, System.Convert.ToInt64(metric.ValueAsString), timestamp);
 }
        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 LogCounter(IRequest request, MetricName metricName, CounterMetric metric, long timestamp)
 {
     request.AddCounter(new DatadogCounter(_nameFormatter.Format(metricName.Name, _path), metric.Count, timestamp, _globalTags));
 }