internal static int GetRollingCount(this ICommandMetrics metrics, CommandExecutionEventEnum status)
        {
            var rtn = 0;
            var dic = metrics.GetExecutionEventDistribution();

            dic.TryGetValue(status, out rtn);

            return(rtn);
        }
        internal FailurePercentageCircuitBreaker(GroupKey key, IClock clock, ICommandMetrics metrics, IStats stats, IMetricEvents metricEvents, FailurePercentageCircuitBreakerProperties properties, IConfigurableValue<long> gaugeIntervalMillisOverride = null)
        {
            _key = key;
            _clock = clock;
            _metrics = metrics;

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

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

            _stats = stats;
            _metricEvents = metricEvents;

            Properties = properties;
            _state = State.Fixed; // Start off assuming everything's fixed.
            _lastTrippedTimestamp = 0; // 0 is fine since it'll be far less than the first compared value.

            // Old gauge, will be phased out in v3.0 when IStats are removed.
            _statsTimer = new GaugeTimer((source, args) =>
            {
                var snapshot = _metrics.GetSnapshot();
                _stats.Gauge(StatsPrefix + " total", snapshot.Total >= properties.MinimumOperations.Value ? "Above" : "Below", snapshot.Total);
                _stats.Gauge(StatsPrefix + " error", snapshot.ErrorPercentage >= properties.ThresholdPercentage.Value ? "Above" : "Below", snapshot.ErrorPercentage);
            }, gaugeIntervalMillisOverride);

            _metricsTimer = new GaugeTimer((source, args) =>
            {
                _metricEvents.BreakerConfigGauge(
                    Name,
                    Properties.MinimumOperations.Value,
                    Properties.ThresholdPercentage.Value,
                    Properties.TrippedDurationMillis.Value);
            }, ConfigGaugeIntervalMillis);
        }
 internal FailurePercentageCircuitBreaker(GroupKey key, ICommandMetrics metrics, IStats stats, FailurePercentageCircuitBreakerProperties properties)
     : this(key, new SystemClock(), metrics, stats, properties) {}
Пример #4
0
 public static CommandMetrics ToConcrete(this ICommandMetrics metrics)
 {
     return((CommandMetrics)metrics);
 }