Exemplo n.º 1
0
        public async Task can_clear_metrics_at_runtime()
        {
            var counterOptions = new CounterOptions
            {
                Name            = "request counter",
                MeasurementUnit = Unit.Requests,
            };
            var counter = _fixture.Metrics.Advanced.Counter(counterOptions);

            counter.Increment();

            var data = await _fixture.CurrentData(_fixture.Metrics);

            var counterValue = data.Contexts.Single().Counters.Single();

            counterValue.Value.Count.Should().Be(1);

            _fixture.Metrics.Advanced.Data.Reset();

            data = await _fixture.CurrentData(_fixture.Metrics);

            data.Contexts.Should().BeNullOrEmpty();
        }
Exemplo n.º 2
0
        public void Can_clear_metrics_at_runtime()
        {
            var counterOptions = new CounterOptions
            {
                Name            = "request counter",
                MeasurementUnit = Unit.Requests,
            };

            _fixture.Metrics.Measure.Counter.Increment(counterOptions);

            var data         = _fixture.CurrentData(_fixture.Metrics);
            var counterValue = data.Contexts.Single().Counters.Single();

            counterValue.Value.Count.Should().Be(1);

            _fixture.Metrics.Manage.Reset();

            data = _fixture.CurrentData(_fixture.Metrics);
            data.Contexts.Should().BeNullOrEmpty();
        }
Exemplo n.º 3
0
        public void can_propergate_value_tags()
        {
            var tags           = new MetricTags("tag", "value");
            var counterOptions = new CounterOptions
            {
                Name            = "test",
                MeasurementUnit = Unit.None,
                Tags            = tags
            };

            var meterOptions = new MeterOptions
            {
                Name            = "test",
                MeasurementUnit = Unit.None,
                Tags            = tags
            };

            var histogramOptions = new HistogramOptions
            {
                Name            = "test",
                MeasurementUnit = Unit.None,
                Tags            = tags
            };

            var timerOptions = new TimerOptions
            {
                Name            = "test",
                MeasurementUnit = Unit.None,
                Tags            = tags
            };

            _fixture.Metrics.Measure.Counter.Increment(counterOptions);
            _fixture.Metrics.Measure.Meter.Mark(meterOptions);
            _fixture.Metrics.Measure.Histogram.Update(histogramOptions, 1);
            _fixture.Metrics.Measure.Timer.Time(timerOptions, () => { });

            var data    = _fixture.CurrentData(_fixture.Metrics);
            var context = data.Contexts.Single();

            context.Counters.Single().Tags.ShouldBeEquivalentTo(tags);
            context.Meters.Single().Tags.ShouldBeEquivalentTo(tags);
            context.Histograms.Single().Tags.ShouldBeEquivalentTo(tags);
            context.Timers.Single().Tags.ShouldBeEquivalentTo(tags);
        }