public bool IsOpen() { if (this.forceShortCircuit) { return(true); } else { return(metrics.GetCumulativeCount(HystrixRollingNumberEvent.Failure) >= 3); } }
public static List <HystrixCommandInfo> GetHystrixCommandInfo(string servicePath) { var result = new List <HystrixCommandInfo>(); ServiceMetadata metadata = EndpointHost.Config.MetadataMap[servicePath]; foreach (Operation operation in metadata.Operations) { HystrixCommandMetrics commandMetrics = operation.HystrixCommand.Metrics; IHystrixCircuitBreaker circuitBreaker = operation.HystrixCommand.CircuitBreaker; HealthCounts healthCounts = commandMetrics.GetHealthCounts(); IHystrixCommandProperties commandProperties = commandMetrics.Properties; var commandInfo = new HystrixCommandInfo { Type = "HystrixCommand", Name = commandMetrics.OperationName, Group = commandMetrics.FullServiceName, CurrentTime = DateTime.Now, IsCircuitBreakerOpen = (circuitBreaker == null ? false : circuitBreaker.IsOpen()), ErrorPercentage = healthCounts.ErrorPercentage, ErrorCount = healthCounts.TotalErrorCount, RequestCount = healthCounts.TotalRequests, RollingCountSuccess = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.Success), RollingCountShortCircuited = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.ShortCircuited), RollingCountTimeout = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.Timeout), RollingCountThreadPoolRejected = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.ThreadPoolRejected), RollingCountFrameworkExceptionThrown = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.FrameworkExceptionThrown), RollingCountServiceExceptionThrown = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.ServiceExceptionThrown), RollingCountValidationExceptionThrown = commandMetrics.GetRollingCount(HystrixRollingNumberEvent.ValidationExceptionThrown), CumulativeCountSuccess = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.Success), CumulativeCountShortCircuited = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.ShortCircuited), CumulativeCountTimeout = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.Timeout), CumulativeCountThreadPoolRejected = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.ThreadPoolRejected), CumulativeCountFrameworkExcetpionThrown = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.FrameworkExceptionThrown), CumulativeCountServiceExceptionThrown = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.ServiceExceptionThrown), CumulativeCountValidationExceptionThrown = commandMetrics.GetCumulativeCount(HystrixRollingNumberEvent.ValidationExceptionThrown), CurrentConcurrentExecutionCount = commandMetrics.CurrentConcurrentExecutionCount, LatencyExecuteMean = commandMetrics.GetServiceExecutionTimeMean(), LatencyExecute = new PercentileInfo { P0 = commandMetrics.GetServiceExecutionTimePercentile(0), P25 = commandMetrics.GetServiceExecutionTimePercentile(25), P50 = commandMetrics.GetServiceExecutionTimePercentile(50), P75 = commandMetrics.GetServiceExecutionTimePercentile(75), P90 = commandMetrics.GetServiceExecutionTimePercentile(90), P95 = commandMetrics.GetServiceExecutionTimePercentile(95), P99 = commandMetrics.GetServiceExecutionTimePercentile(99), P99DOT5 = commandMetrics.GetServiceExecutionTimePercentile(99.5), P100 = commandMetrics.GetServiceExecutionTimePercentile(100), }, LatencyTotalMean = commandMetrics.GetTotalTimeMean(), LatencyTotal = new PercentileInfo { P0 = commandMetrics.GetTotalTimePercentile(0), P25 = commandMetrics.GetTotalTimePercentile(25), P50 = commandMetrics.GetTotalTimePercentile(50), P75 = commandMetrics.GetTotalTimePercentile(75), P90 = commandMetrics.GetTotalTimePercentile(90), P95 = commandMetrics.GetTotalTimePercentile(95), P99 = commandMetrics.GetTotalTimePercentile(99), P99DOT5 = commandMetrics.GetTotalTimePercentile(99.5), P100 = commandMetrics.GetTotalTimePercentile(100), }, PropertyValue_CircuitBreakerRequestVolumeThreshold = commandProperties.CircuitBreakerRequestVolumeThreshold.Get(), PropertyValue_CircuitBreakerSleepWindowInMilliseconds = (long)commandProperties.CircuitBreakerSleepWindow.Get().TotalMilliseconds, PropertyValue_CircuitBreakerErrorThresholdPercentage = commandProperties.CircuitBreakerErrorThresholdPercentage.Get(), PropertyValue_CircuitBreakerForceOpen = commandProperties.CircuitBreakerForceOpen.Get(), PropertyValue_CircuitBreakerForceClosed = commandProperties.CircuitBreakerForceClosed.Get(), PropertyValue_CircuitBreakerEnabled = commandProperties.CircuitBreakerEnabled.Get(), PropertyValue_ExecutionIsolationThreadTimeoutInMilliseconds = (long)operation.HystrixCommand.GetExecutionTimeout().TotalMilliseconds, PropertyValue_MetricsRollingStatisticalWindowInMilliseconds = commandProperties.MetricsRollingStatisticalWindowInMilliseconds.Get(), PropertyValue_RequestLogEnabled = commandProperties.RequestLogEnabled.Get(), ReportingHosts = 1, }; result.Add(commandInfo); } return(result); }
protected IMonitor <long> getCumulativeMonitor(string name, HystrixEventType @event) { return(ServoMetricFactory.CounterMetric <long>(this, MonitorConfig.builder(name).withTag(ServoTypeTag).withTag(ServoInstanceTag).build(), () => metrics.GetCumulativeCount(@event.ToHystrixRollingNumberEvent()))); }