public static List <HystrixCommandInfo> GetHystrixCommandInfoList() { List <HystrixCommandInfo> list = new List <HystrixCommandInfo>(); foreach (CommandComponents components in HystrixCommandBase.CommandComponentsCollection.Values.ToArray <CommandComponents>()) { CommandExecutionHealthSnapshot executionHealthSnapshot = components.Metrics.GetExecutionHealthSnapshot(); Dictionary <CommandExecutionEventEnum, int> executionEventDistribution = components.Metrics.GetExecutionEventDistribution(); HystrixCommandInfo info2 = new HystrixCommandInfo { type = "HystrixCommand", name = components.CommandInfo.Key, group = (components.CommandInfo.InstanceKey == null) ? components.CommandInfo.GroupKey : components.CommandInfo.CommandKey, currentTime = CommonUtils.CurrentUnixTimeInMilliseconds, isCircuitBreakerOpen = components.CircuitBreaker.IsOpen(), errorPercentage = executionHealthSnapshot.ErrorPercentage, errorCount = ((IEnumerable <int>)(from p in executionEventDistribution where CommonUtils.CoreFailedCommandExecutionEvents.Contains <CommandExecutionEventEnum>(p.Key) select p.Value)).Sum(), requestCount = ((IEnumerable <int>)(from p in executionEventDistribution where CommonUtils.CoreCommandExecutionEvents.Contains <CommandExecutionEventEnum>(p.Key) select p.Value)).Sum(), rollingCountExceptionsThrown = (long)executionEventDistribution[CommandExecutionEventEnum.ExceptionThrown], rollingCountFailure = (long)executionEventDistribution[CommandExecutionEventEnum.Failed], rollingCountSemaphoreRejected = (components.IsolationMode == IsolationModeEnum.SemaphoreIsolation) ? ((long)executionEventDistribution[CommandExecutionEventEnum.Rejected]) : ((long)0), rollingCountShortCircuited = (long)executionEventDistribution[CommandExecutionEventEnum.ShortCircuited], rollingCountSuccess = (long)executionEventDistribution[CommandExecutionEventEnum.Success], rollingCountThreadPoolRejected = (components.IsolationMode == IsolationModeEnum.ThreadIsolation) ? ((long)executionEventDistribution[CommandExecutionEventEnum.Rejected]) : ((long)0), rollingCountTimeout = (long)executionEventDistribution[CommandExecutionEventEnum.Timeout], rollingCountFallbackFailure = (long)executionEventDistribution[CommandExecutionEventEnum.FallbackFailed], rollingCountFallbackSuccess = (long)executionEventDistribution[CommandExecutionEventEnum.FallbackSuccess], rollingCountFallbackRejection = (long)executionEventDistribution[CommandExecutionEventEnum.FallbackRejected] }; PercentileInfo info3 = new PercentileInfo { P0 = components.Metrics.GetExecutionLatencyPencentile(0.0), P25 = components.Metrics.GetExecutionLatencyPencentile(25.0), P50 = components.Metrics.GetExecutionLatencyPencentile(50.0), P75 = components.Metrics.GetExecutionLatencyPencentile(75.0), P90 = components.Metrics.GetExecutionLatencyPencentile(90.0), P95 = components.Metrics.GetExecutionLatencyPencentile(95.0), P99 = components.Metrics.GetExecutionLatencyPencentile(99.0), P99DOT5 = components.Metrics.GetExecutionLatencyPencentile(99.5), P100 = components.Metrics.GetExecutionLatencyPencentile(100.0) }; info2.latencyExecute = info3; info2.latencyExecute_mean = components.Metrics.GetAverageExecutionLatency(); PercentileInfo info4 = new PercentileInfo { P0 = components.Metrics.GetTotalExecutionLatencyPencentile(0.0), P25 = components.Metrics.GetTotalExecutionLatencyPencentile(25.0), P50 = components.Metrics.GetTotalExecutionLatencyPencentile(50.0), P75 = components.Metrics.GetTotalExecutionLatencyPencentile(75.0), P90 = components.Metrics.GetTotalExecutionLatencyPencentile(90.0), P95 = components.Metrics.GetTotalExecutionLatencyPencentile(95.0), P99 = components.Metrics.GetTotalExecutionLatencyPencentile(99.0), P99DOT5 = components.Metrics.GetTotalExecutionLatencyPencentile(99.5), P100 = components.Metrics.GetTotalExecutionLatencyPencentile(100.0) }; info2.latencyTotal = info4; info2.latencyTotal_mean = components.Metrics.GetAverageTotalExecutionLatency(); info2.reportingHosts = 1; info2.propertyValue_circuitBreakerEnabled = components.ConfigSet.CircuitBreakerEnabled; info2.propertyValue_circuitBreakerErrorThresholdPercentage = components.ConfigSet.CircuitBreakerErrorThresholdPercentage; info2.propertyValue_circuitBreakerForceClosed = components.ConfigSet.CircuitBreakerForceClosed; info2.propertyValue_circuitBreakerForceOpen = components.ConfigSet.CircuitBreakerForceOpen; info2.propertyValue_circuitBreakerRequestVolumeThreshold = components.ConfigSet.CircuitBreakerRequestCountThreshold; info2.propertyValue_circuitBreakerSleepWindowInMilliseconds = components.ConfigSet.CircuitBreakerSleepWindowInMilliseconds; info2.propertyValue_executionIsolationSemaphoreMaxConcurrentRequests = components.ConfigSet.CommandMaxConcurrentCount; info2.propertyValue_executionIsolationStrategy = (components.IsolationMode == IsolationModeEnum.SemaphoreIsolation) ? "SEMAPHORE" : "THREAD"; info2.propertyValue_executionIsolationThreadTimeoutInMilliseconds = components.ConfigSet.CommandTimeoutInMilliseconds; info2.propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests = components.ConfigSet.FallbackMaxConcurrentCount; info2.propertyValue_metricsRollingStatisticalWindowInMilliseconds = components.ConfigSet.MetricsRollingStatisticalWindowInMilliseconds; info2.currentConcurrentExecutionCount = components.Metrics.CurrentConcurrentExecutionCount; HystrixCommandInfo item = info2; list.Add(item); } return(list); }
public static List <HystrixCommandInfo> GetHystrixCommandInfoList() { List <HystrixCommandInfo> hystrixCommandInfoList = new List <HystrixCommandInfo>(); CommandComponents[] commandComponentsList = HystrixCommandBase.CommandComponentsCollection.Values.ToArray(); foreach (CommandComponents item in commandComponentsList) { CommandExecutionHealthSnapshot healthSnapshot = item.Metrics.GetExecutionHealthSnapshot(); Dictionary <CommandExecutionEventEnum, int> commandExecutionEventDistribution = item.Metrics.GetExecutionEventDistribution(); HystrixCommandInfo hystrixCommandInfo = new HystrixCommandInfo() { type = TurbineDataTypeHystrixCommand, name = item.CommandInfo.Key, group = item.CommandInfo.InstanceKey == null ? item.CommandInfo.GroupKey : item.CommandInfo.CommandKey, currentTime = CommonUtils.CurrentUnixTimeInMilliseconds, isCircuitBreakerOpen = item.CircuitBreaker.IsOpen(), errorPercentage = healthSnapshot.ErrorPercentage, errorCount = commandExecutionEventDistribution.Where(p => CommonUtils.CoreFailedCommandExecutionEvents.Contains(p.Key)).Select(p => p.Value).Sum(), requestCount = commandExecutionEventDistribution.Where(p => CommonUtils.CoreCommandExecutionEvents.Contains(p.Key)).Select(p => p.Value).Sum(), rollingCountExceptionsThrown = commandExecutionEventDistribution[CommandExecutionEventEnum.ExceptionThrown], rollingCountFailure = commandExecutionEventDistribution[CommandExecutionEventEnum.Failed], rollingCountSemaphoreRejected = item.IsolationMode == IsolationModeEnum.SemaphoreIsolation ? commandExecutionEventDistribution[CommandExecutionEventEnum.Rejected] : 0, rollingCountShortCircuited = commandExecutionEventDistribution[CommandExecutionEventEnum.ShortCircuited], rollingCountSuccess = commandExecutionEventDistribution[CommandExecutionEventEnum.Success], rollingCountThreadPoolRejected = item.IsolationMode == IsolationModeEnum.ThreadIsolation ? commandExecutionEventDistribution[CommandExecutionEventEnum.Rejected] : 0, rollingCountTimeout = commandExecutionEventDistribution[CommandExecutionEventEnum.Timeout], rollingCountFallbackFailure = commandExecutionEventDistribution[CommandExecutionEventEnum.FallbackFailed], rollingCountFallbackSuccess = commandExecutionEventDistribution[CommandExecutionEventEnum.FallbackSuccess], rollingCountFallbackRejection = commandExecutionEventDistribution[CommandExecutionEventEnum.FallbackRejected], latencyExecute = new PercentileInfo() { P0 = item.Metrics.GetExecutionLatencyPencentile(0), P25 = item.Metrics.GetExecutionLatencyPencentile(25), P50 = item.Metrics.GetExecutionLatencyPencentile(50), P75 = item.Metrics.GetExecutionLatencyPencentile(75), P90 = item.Metrics.GetExecutionLatencyPencentile(90), P95 = item.Metrics.GetExecutionLatencyPencentile(95), P99 = item.Metrics.GetExecutionLatencyPencentile(99), P99DOT5 = item.Metrics.GetExecutionLatencyPencentile(99.5), P100 = item.Metrics.GetExecutionLatencyPencentile(100) }, latencyExecute_mean = item.Metrics.GetAverageExecutionLatency(), latencyTotal = new PercentileInfo() { P0 = item.Metrics.GetTotalExecutionLatencyPencentile(0), P25 = item.Metrics.GetTotalExecutionLatencyPencentile(25), P50 = item.Metrics.GetTotalExecutionLatencyPencentile(50), P75 = item.Metrics.GetTotalExecutionLatencyPencentile(75), P90 = item.Metrics.GetTotalExecutionLatencyPencentile(90), P95 = item.Metrics.GetTotalExecutionLatencyPencentile(95), P99 = item.Metrics.GetTotalExecutionLatencyPencentile(99), P99DOT5 = item.Metrics.GetTotalExecutionLatencyPencentile(99.5), P100 = item.Metrics.GetTotalExecutionLatencyPencentile(100) }, latencyTotal_mean = item.Metrics.GetAverageTotalExecutionLatency(), reportingHosts = 1, propertyValue_circuitBreakerEnabled = item.ConfigSet.CircuitBreakerEnabled, propertyValue_circuitBreakerErrorThresholdPercentage = item.ConfigSet.CircuitBreakerErrorThresholdPercentage, propertyValue_circuitBreakerForceClosed = item.ConfigSet.CircuitBreakerForceClosed, propertyValue_circuitBreakerForceOpen = item.ConfigSet.CircuitBreakerForceOpen, propertyValue_circuitBreakerRequestVolumeThreshold = item.ConfigSet.CircuitBreakerRequestCountThreshold, propertyValue_circuitBreakerSleepWindowInMilliseconds = item.ConfigSet.CircuitBreakerSleepWindowInMilliseconds, propertyValue_executionIsolationSemaphoreMaxConcurrentRequests = item.ConfigSet.CommandMaxConcurrentCount, propertyValue_executionIsolationStrategy = item.IsolationMode == IsolationModeEnum.SemaphoreIsolation ? TurbineStrategySemaphore : TurbineStrategyThread, propertyValue_executionIsolationThreadTimeoutInMilliseconds = item.ConfigSet.CommandTimeoutInMilliseconds, propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests = item.ConfigSet.FallbackMaxConcurrentCount, propertyValue_metricsRollingStatisticalWindowInMilliseconds = item.ConfigSet.MetricsRollingStatisticalWindowInMilliseconds, currentConcurrentExecutionCount = item.Metrics.CurrentConcurrentExecutionCount, }; hystrixCommandInfoList.Add(hystrixCommandInfo); } return(hystrixCommandInfoList); }