コード例 #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);
        }
コード例 #2
0
        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;
        }