예제 #1
0
        internal StandardCommandMetrics(GroupKey key, IFailurePercentageCircuitBreakerConfig config, IClock clock, IMjolnirLogFactory logFactory)
        {
            _config = config ?? throw new ArgumentNullException(nameof(config));
            _clock  = clock ?? throw new ArgumentNullException(nameof(clock));

            _key = key;
            _resettingNumbersBucket = new ResettingNumbersBucket(_key, _clock, _config, logFactory);
        }
        public void Increment_AfterPeriodExceeded_ResetsBeforeIncrementing()
        {
            const long periodMillis = 1000;
            var clock = new ManualTestClock();
            var bucket = new ResettingNumbersBucket(clock, new TransientConfigurableValue<long>(periodMillis));

            bucket.Increment(CounterMetric.CommandSuccess);

            clock.AddMilliseconds(periodMillis + 1);
            Assert.Equal(1, bucket.GetCount(CounterMetric.CommandSuccess));

            bucket.Increment(CounterMetric.CommandSuccess); // Should reset and then count one.
            Assert.Equal(1, bucket.GetCount(CounterMetric.CommandSuccess)); // Should be 1, not 2.
        }
예제 #3
0
        internal StandardCommandMetrics(GroupKey key, IConfigurableValue <long> windowMillis, IConfigurableValue <long> snapshotTtlMillis, IClock clock, IStats stats)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            _key                    = key;
            _clock                  = clock;
            _snapshotTtlMillis      = snapshotTtlMillis;
            _resettingNumbersBucket = new ResettingNumbersBucket(_clock, windowMillis);

            if (stats == null)
            {
                throw new ArgumentNullException("stats");
            }
            _stats = stats;
        }
예제 #4
0
        internal StandardCommandMetrics(GroupKey key, IConfigurableValue<long> windowMillis, IConfigurableValue<long> snapshotTtlMillis, IClock clock, IStats stats)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            _key = key;
            _clock = clock;
            _snapshotTtlMillis = snapshotTtlMillis;
            _resettingNumbersBucket = new ResettingNumbersBucket(_clock, windowMillis);

            if (stats == null)
            {
                throw new ArgumentNullException("stats");
            }
            _stats = stats;
        }