Пример #1
0
        public async Task Can_report_meters_when_multidimensional()
        {
            // Arrange
            var expected =
                "env.staging.meter.test.test_meter.host.server1.Total 1 1483232461\nenv.staging.meter.test.test_meter.host.server1.Rate-1-Min 0.00 1483232461\nenv.staging.meter.test.test_meter.host.server1.Rate-5-Min 0.00 1483232461\nenv.staging.meter.test.test_meter.host.server1.Rate-15-Min 0.00 1483232461\n";
            var clock = new TestClock();
            var meter = new DefaultMeterMetric(clock);

            meter.Mark(1);
            var meterValueSource = new MeterValueSource(
                "test meter" + MultidimensionalMetricNameSuffix,
                ConstantValue.Provider(meter.Value),
                Unit.None,
                TimeUnit.Milliseconds,
                _tags);

            // Act
            var valueSource = CreateValueSource("test", meters: meterValueSource);

            // Assert
            await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected);
        }
        public void Can_report_timers__when_multidimensional()
        {
            // Arrange
            var expected =
                "env.staging.timer.test.test_timer.host.server1.Total 1 1483232461\nenv.staging.timer.test.test_timer.host.server1.Rate-1-Min 0.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Rate-5-Min 0.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Rate-15-Min 0.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Samples 1 1483232461\nenv.staging.timer.test.test_timer.host.server1.Last 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Count 1 1483232461\nenv.staging.timer.test.test_timer.host.server1.Sum 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Min 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Max 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Mean 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Median 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.StdDev 0.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Percentile-999 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Percentile-99 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Percentile-98 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Percentile-95 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.Percentile-75 1000.00 1483232461\nenv.staging.timer.test.test_timer.host.server1.User-Last client1 1483232461\nenv.staging.timer.test.test_timer.host.server1.User-Min client1 1483232461\nenv.staging.timer.test.test_timer.host.server1.User-Max client1 1483232461\n";
            var clock = new TestClock();
            var timer = new DefaultTimerMetric(_defaultReservoir, clock);

            timer.Record(1000, TimeUnit.Milliseconds, "client1");
            var timerValueSource = new TimerValueSource(
                "test timer" + MultidimensionalMetricNameSuffix,
                ConstantValue.Provider(timer.Value),
                Unit.None,
                TimeUnit.Milliseconds,
                TimeUnit.Milliseconds,
                _tags);

            // Act
            var valueSource = CreateValueSource("test", timers: timerValueSource);

            // Assert
            AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected);
        }
        public void Can_report_timers()
        {
            // Arrange
            var expected =
                "timer.test.test_timer.Total 1 1483232461\ntimer.test.test_timer.Rate-1-Min 0.00 1483232461\ntimer.test.test_timer.Rate-5-Min 0.00 1483232461\ntimer.test.test_timer.Rate-15-Min 0.00 1483232461\ntimer.test.test_timer.Samples 1 1483232461\ntimer.test.test_timer.Last 1000.00 1483232461\ntimer.test.test_timer.Count 1 1483232461\ntimer.test.test_timer.Sum 1000.00 1483232461\ntimer.test.test_timer.Min 1000.00 1483232461\ntimer.test.test_timer.Max 1000.00 1483232461\ntimer.test.test_timer.Mean 1000.00 1483232461\ntimer.test.test_timer.Median 1000.00 1483232461\ntimer.test.test_timer.StdDev 0.00 1483232461\ntimer.test.test_timer.Percentile-999 1000.00 1483232461\ntimer.test.test_timer.Percentile-99 1000.00 1483232461\ntimer.test.test_timer.Percentile-98 1000.00 1483232461\ntimer.test.test_timer.Percentile-95 1000.00 1483232461\ntimer.test.test_timer.Percentile-75 1000.00 1483232461\ntimer.test.test_timer.User-Last client1 1483232461\ntimer.test.test_timer.User-Min client1 1483232461\ntimer.test.test_timer.User-Max client1 1483232461\n";
            var clock = new TestClock();
            var timer = new DefaultTimerMetric(_defaultReservoir, clock);

            timer.Record(1000, TimeUnit.Milliseconds, "client1");
            var timerValueSource = new TimerValueSource(
                "test timer",
                ConstantValue.Provider(timer.Value),
                Unit.None,
                TimeUnit.Milliseconds,
                TimeUnit.Milliseconds,
                MetricTags.Empty);

            // Act
            var valueSource = CreateValueSource("test", timers: timerValueSource);

            // Assert
            AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected);
        }
        public void Can_report_meters_with_items_tags_when_multidimensional()
        {
            // Arrange
            var expected =
                "env.staging.meter.test.test_meter-SetItem.host.server1.item.item1_value1.Total 1 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item1_value1.Rate-1-Min 0.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item1_value1.Rate-5-Min 0.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item1_value1.Rate-15-Min 0.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item1_value1.Percent 50.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item2_value2.Total 1 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item2_value2.Rate-1-Min 0.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item2_value2.Rate-5-Min 0.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item2_value2.Rate-15-Min 0.00 1483232461\nenv.staging.meter.test.test_meter-SetItem.host.server1.item.item2_value2.Percent 50.00 1483232461\nenv.staging.meter.test.test_meter.host.server1.Total 2 1483232461\nenv.staging.meter.test.test_meter.host.server1.Rate-1-Min 0.00 1483232461\nenv.staging.meter.test.test_meter.host.server1.Rate-5-Min 0.00 1483232461\nenv.staging.meter.test.test_meter.host.server1.Rate-15-Min 0.00 1483232461\n";
            var clock = new TestClock();
            var meter = new DefaultMeterMetric(clock);

            meter.Mark(new MetricSetItem("item1", "value1"), 1);
            meter.Mark(new MetricSetItem("item2", "value2"), 1);
            var meterValueSource = new MeterValueSource(
                "test meter" + MultidimensionalMetricNameSuffix,
                ConstantValue.Provider(meter.Value),
                Unit.None,
                TimeUnit.Milliseconds,
                _tags);

            // Act
            var valueSource = CreateValueSource("test", meters: meterValueSource);

            // Assert
            AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected);
        }
        public void Can_report_meters_with_items()
        {
            // Arrange
            var expected =
                "meter.test.test_meter-SetItem.item.item1_value1.Total 1 1483232461\nmeter.test.test_meter-SetItem.item.item1_value1.Rate-1-Min 0.00 1483232461\nmeter.test.test_meter-SetItem.item.item1_value1.Rate-5-Min 0.00 1483232461\nmeter.test.test_meter-SetItem.item.item1_value1.Rate-15-Min 0.00 1483232461\nmeter.test.test_meter-SetItem.item.item1_value1.Percent 50.00 1483232461\nmeter.test.test_meter-SetItem.item.item2_value2.Total 1 1483232461\nmeter.test.test_meter-SetItem.item.item2_value2.Rate-1-Min 0.00 1483232461\nmeter.test.test_meter-SetItem.item.item2_value2.Rate-5-Min 0.00 1483232461\nmeter.test.test_meter-SetItem.item.item2_value2.Rate-15-Min 0.00 1483232461\nmeter.test.test_meter-SetItem.item.item2_value2.Percent 50.00 1483232461\nmeter.test.test_meter.Total 2 1483232461\nmeter.test.test_meter.Rate-1-Min 0.00 1483232461\nmeter.test.test_meter.Rate-5-Min 0.00 1483232461\nmeter.test.test_meter.Rate-15-Min 0.00 1483232461\n";
            var clock = new TestClock();
            var meter = new DefaultMeterMetric(clock);

            meter.Mark(new MetricSetItem("item1", "value1"), 1);
            meter.Mark(new MetricSetItem("item2", "value2"), 1);
            var meterValueSource = new MeterValueSource(
                "test meter",
                ConstantValue.Provider(meter.Value),
                Unit.None,
                TimeUnit.Milliseconds,
                MetricTags.Empty);

            // Act
            var valueSource = CreateValueSource("test", meters: meterValueSource);

            // Assert
            AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected);
        }