public async Task Can_report_meters_with_items_tags_when_multidimensional() { // Arrange var expected = "test.test_meter__items.meter.item1:value1.value:1|m\n" + "test.test_meter__items.meter.item2:value2.value:1|m\n" + "test.test_meter.meter.value:2|m"; 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 await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public void can_calculate_the_hit_ratio_as_a_guage_with_one_min_rate_as_default() { var clock = new TestClock(); var scheduler = new TestTaskScheduler(clock); var cacheHitMeter = new DefaultMeterMetric(clock, scheduler); var dbQueryTimer = new DefaultTimerMetric(new DefaultAlgorithmRReservoir(1028), clock); foreach (var index in Enumerable.Range(0, 1000)) { using (dbQueryTimer.NewContext()) { clock.Advance(TimeUnit.Milliseconds, 100); } if (index % 2 == 0) { cacheHitMeter.Mark(); } } var cacheHitRatioGauge = new HitRatioGauge(cacheHitMeter, dbQueryTimer); cacheHitRatioGauge.Value.Should().BeGreaterThan(0.0); }
public void can_report_meters_when_multidimensional() { var metricsMock = new Mock <IMetrics>(); 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); var payloadBuilder = new TestPayloadBuilder(); var reporter = new TestReporter(payloadBuilder); reporter.StartReportRun(metricsMock.Object); reporter.ReportMetric("test", meterValueSource); payloadBuilder.PayloadFormatted(). Should(). Be( "test__test_meter host=server1 env=staging mtype=meter count.meter=1i rate1m=0 rate5m=0 rate15m=0" + Environment.NewLine); }
public async Task Meters_should_not_be_sampled() { // Arrange var sources = new List <MetricsDataValueSource>(); var timeStamp = _timestamp; var expected = "test.test_meter.meter.value:4|c"; // Act for (var i = 0; i < 100; ++i) { sources.Add(CreateMetricsDataValueSource(ref timeStamp)); } var emittedData = (await Serialize(sources, 0.5)).Split('\n'); // Assert emittedData.Length.Should().Be(100); emittedData[0].Should().Be(expected); MetricsDataValueSource CreateMetricsDataValueSource(ref DateTime timestamp) { var clock = new TestClock(); var meter = new DefaultMeterMetric(clock); meter.Mark(1); meter.Mark(1); meter.Mark(1); meter.Mark(1); var meterValueSource = new MeterValueSource( "test meter", ConstantValue.Provider(meter.Value), Unit.None, TimeUnit.Milliseconds, MetricTags.Empty); var valueSource = CreateValueSource("test", meters: meterValueSource); var result = new MetricsDataValueSource(timestamp, new[] { valueSource }); timestamp += TimeSpan.FromSeconds(1); return(result); } }
public void can_report_meters() { var expected = StringReporterSamples.Meters.ExtractStringReporterSampleFromResourceFile(); var clock = new TestClock(); var sr = new StringReporter(); var metric = new DefaultMeterMetric(clock, new TestTaskScheduler(clock)); metric.Mark(1); sr.ReportMetric("test", new MeterValueSource("meter_name", metric, Unit.None, TimeUnit.Milliseconds, MetricTags.None)); AssertReportResult(sr.Result, expected); }
public void Can_report_meters_with_items_tags_when_multidimensional() { // Arrange var expected = "test__test_meter__items,host=server1,env=staging,item=item1:value1,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0,percent=50 1483232461000000000\ntest__test_meter__items,host=server1,env=staging,item=item2:value2,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0,percent=50 1483232461000000000\ntest__test_meter,host=server1,env=staging,mtype=meter,unit=none,unit_rate=ms count.meter=2i,rate1m=0,rate5m=0,rate15m=0 1483232461000000000\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 async Task Can_report_meters_with_items() { // Arrange var expected = "test__test_meter__items,item=item1:value1,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0,percent=50 1483232461000000000\ntest__test_meter__items,item=item2:value2,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0,percent=50 1483232461000000000\ntest__test_meter,mtype=meter,unit=none,unit_rate=ms count.meter=2i,rate1m=0,rate5m=0,rate15m=0 1483232461000000000\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 await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public async Task Can_report_meters_with_items_tags_when_multidimensional() { // Arrange var expected = "{\"series\":[{\"metric\":\"test.test_meter__items.meter.count.meter\",\"points\":[[1483232461,1]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item1:value1\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.rate1m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item1:value1\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.rate5m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item1:value1\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.rate15m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item1:value1\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.percent\",\"points\":[[1483232461,50]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item1:value1\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.count.meter\",\"points\":[[1483232461,1]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item2:value2\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.rate1m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item2:value2\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.rate5m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item2:value2\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.rate15m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item2:value2\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter__items.meter.percent\",\"points\":[[1483232461,50]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"item:item2:value2\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.count.meter\",\"points\":[[1483232461,2]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.rate1m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.rate5m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.rate15m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"host:server1\",\"env:staging\",\"unit:none\",\"unit_rate:ms\"]}]}"; 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 await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), FlushInterval, 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); }
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_tags_when_multidimensional() { var metricsMock = new Mock <IMetrics>(); 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); var items = CreateReporterAndPayloadBuilder(); items.Item1.StartReportRun(metricsMock.Object); items.Item1.ReportMetric("test", meterValueSource); items.Item2.PayloadFormatted(). Should(). Be( "test__test_meter__items host=server1 env=staging item=item1:value1 mtype=meter unit=none unit_rate=ms count.meter=1i rate1m=0 rate5m=0 rate15m=0 percent=50" + Environment.NewLine + "test__test_meter__items host=server1 env=staging item=item2:value2 mtype=meter unit=none unit_rate=ms count.meter=1i rate1m=0 rate5m=0 rate15m=0 percent=50" + Environment.NewLine + "test__test_meter host=server1 env=staging mtype=meter unit=none unit_rate=ms count.meter=2i rate1m=0 rate5m=0 rate15m=0" + Environment.NewLine); }
public void can_report_meters() { var metricsMock = new Mock <IMetrics>(); var clock = new TestClock(); var meter = new DefaultMeterMetric(clock); meter.Mark(1); var meterValueSource = new MeterValueSource( "test meter", ConstantValue.Provider(meter.Value), Unit.None, TimeUnit.Milliseconds, MetricTags.Empty); var items = CreateReporterAndPayloadBuilder(); items.Item1.StartReportRun(metricsMock.Object); items.Item1.ReportMetric("test", meterValueSource); items.Item2.PayloadFormatted().Should().Be("test__test_meter mtype=meter unit=none unit_rate=ms count.meter=1i rate1m=0 rate5m=0 rate15m=0" + Environment.NewLine); }
public void Can_report_meters() { // Arrange var expected = "test__test_meter,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0 1483232461000000000\n"; var clock = new TestClock(); var meter = new DefaultMeterMetric(clock); meter.Mark(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); }
public async Task Can_report_meters() { // Arrange var expected = "{\"series\":[{\"metric\":\"test.test_meter.meter.count.meter\",\"points\":[[1483232461,1]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.rate1m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.rate5m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"unit:none\",\"unit_rate:ms\"]},{\"metric\":\"test.test_meter.meter.rate15m\",\"points\":[[1483232461,0]],\"type\":\"rate\",\"interval\":10,\"tags\":[\"unit:none\",\"unit_rate:ms\"]}]}"; var clock = new TestClock(); var meter = new DefaultMeterMetric(clock); meter.Mark(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 await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), FlushInterval, expected); }
public void can_report_meters() { var metricsMock = new Mock <IMetrics>(); var clock = new TestClock(); var meter = new DefaultMeterMetric(clock); meter.Mark(1); var meterValueSource = new MeterValueSource( "test meter", ConstantValue.Provider(meter.Value), Unit.None, TimeUnit.Milliseconds, MetricTags.Empty); var payloadBuilder = new LineProtocolPayloadBuilder(); var reporter = CreateReporter(payloadBuilder); reporter.StartReportRun(metricsMock.Object); reporter.ReportMetric("test", meterValueSource); payloadBuilder.PayloadFormatted().Should().Be("test__test_meter count.meter=1i,rate1m=0,rate5m=0,rate15m=0\n"); }
public async Task Can_report_meters() { // Arrange var expected = "meter.test.test_meter.Total 1 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(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 await AssertExpectedLineProtocolString(new MetricsDataValueSource(_timestamp, new[] { valueSource }), expected); }
public async Task Can_report_meters_when_multidimensional() { // Arrange var expected = "test__test_meter,host=server1,env=staging,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0 1483232461000000000\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_meters() { var metricsMock = new Mock <IMetrics>(); var clock = new TestClock(); var meter = new DefaultMeterMetric(clock); meter.Mark(1); var meterValueSource = new MeterValueSource( "test meter", ConstantValue.Provider(meter.Value), Unit.None, TimeUnit.Milliseconds, MetricTags.Empty); var payloadBuilder = new GraphitePayloadBuilder(_settings.GraphiteSettings.MetricNameFormatter, _settings.DataKeys, Origin); var reporter = CreateReporter(payloadBuilder); reporter.StartReportRun(metricsMock.Object); reporter.ReportMetric("test", meterValueSource); payloadBuilder.PayloadFormatted().Should().Be("meter.test.test_meter.Total 1 0\nmeter.test.test_meter.Rate-1-Min 0.00 0\nmeter.test.test_meter.Rate-5-Min 0.00 0\nmeter.test.test_meter.Rate-15-Min 0.00 0\n"); }
public async Task Can_report_meters_when_multidimensional() { // Arrange var expected = "test.test_meter.meter.value:1|m|#host:server1,env:staging,unit:none,unit_rate:ms,timestamp:1483232461"; 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_calculate_the_hit_ratio_as_a_guage() { var cacheHitMeter = new DefaultMeterMetric(_clock, _schedular); var queryTimer = new DefaultTimerMetric(new DefaultAlgorithmRReservoir(1028), _clock); foreach (var index in Enumerable.Range(0, 1000)) { using (queryTimer.NewContext()) { _clock.Advance(TimeUnit.Milliseconds, 100); } if (index % 2 == 0) { cacheHitMeter.Mark(); } } var cacheHitRatioGauge = new HitRatioGauge(cacheHitMeter, queryTimer, value => value.OneMinuteRate); cacheHitRatioGauge.Value.Should().BeGreaterThan(0.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_meters_when_multidimensional() { var metricsMock = new Mock <IMetrics>(); 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); var payloadBuilder = new LineProtocolPayloadBuilder(_settings.DataKeys, _settings.MetricNameFormatter); var reporter = CreateReporter(payloadBuilder); reporter.StartReportRun(metricsMock.Object); reporter.ReportMetric("test", meterValueSource); payloadBuilder.PayloadFormatted(false). Should(). Be("test__test_meter,host=server1,env=staging,mtype=meter,unit=none,unit_rate=ms count.meter=1i,rate1m=0,rate5m=0,rate15m=0\n"); }
public void can_report_meters_when_multidimensional() { var metricsMock = new Mock <IMetrics>(); 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); var payloadBuilder = new GraphitePayloadBuilder(_settings.GraphiteSettings.MetricNameFormatter, _settings.DataKeys, Origin); var reporter = CreateReporter(payloadBuilder); reporter.StartReportRun(metricsMock.Object); reporter.ReportMetric("test", meterValueSource); payloadBuilder.PayloadFormatted(). Should(). Be("env.staging.meter.test.test_meter.host.server1.Total 1 0\nenv.staging.meter.test.test_meter.host.server1.Rate-1-Min 0.00 0\nenv.staging.meter.test.test_meter.host.server1.Rate-5-Min 0.00 0\nenv.staging.meter.test.test_meter.host.server1.Rate-15-Min 0.00 0\n"); }
public void can_calculate_mean_rate() { _meter.Mark(); _clock.Advance(TimeUnit.Seconds, 1); _meter.Value.MeanRate.Should().Be(1); _clock.Advance(TimeUnit.Seconds, 1); _meter.Value.MeanRate.Should().Be(0.5); }