private static List <GlobalStreamHystrixCommandInfo> GetHystrixCommandInfoList() { var result = new List <GlobalStreamHystrixCommandInfo>(); foreach (ServiceMetadata metadata in EndpointHost.Config.MetadataMap.Values) { string refinedServiceName = ServiceUtils.RefineServiceName(metadata.ServiceNamespace, metadata.ServiceName); foreach (Operation operation in metadata.Operations) { HystrixCommandMetrics commandMetrics = operation.HystrixCommand.Metrics; IHystrixCircuitBreaker circuitBreaker = operation.HystrixCommand.CircuitBreaker; HealthCounts healthCounts = commandMetrics.GetHealthCounts(); IHystrixCommandProperties commandProperties = commandMetrics.Properties; GlobalStreamHystrixCommandInfo hystrixCommandInfo = new GlobalStreamHystrixCommandInfo() { type = TurbineDataTypeHystrixCommand, name = refinedServiceName + "." + operation.Name.ToLower(), group = refinedServiceName, currentTime = DateTime.Now.ToUnixTimeMs(), isCircuitBreakerOpen = circuitBreaker.IsOpen(), errorPercentage = healthCounts.ErrorPercentage, errorCount = healthCounts.TotalErrorCount, requestCount = healthCounts.TotalRequests, rollingCountExceptionsThrown = healthCounts.TotalExceptionCount, rollingCountFailure = healthCounts.TotalFailureCount, rollingCountSemaphoreRejected = 0, rollingCountShortCircuited = healthCounts.ShortCircuitedCount, rollingCountSuccess = healthCounts.SuccessCount, rollingCountThreadPoolRejected = 0, rollingCountTimeout = healthCounts.TimeoutCount, rollingCountFallbackFailure = 0, rollingCountFallbackSuccess = 0, rollingCountFallbackRejection = 0, latencyExecute = new GlobalStreamPercentileInfo() { 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) }, latencyExecute_mean = commandMetrics.GetServiceExecutionTimeMean(), latencyTotal = new GlobalStreamPercentileInfo() { 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) }, latencyTotal_mean = commandMetrics.GetTotalTimeMean(), reportingHosts = 1, propertyValue_circuitBreakerEnabled = commandProperties.CircuitBreakerEnabled.Get(), propertyValue_circuitBreakerErrorThresholdPercentage = commandProperties.CircuitBreakerErrorThresholdPercentage.Get(), propertyValue_circuitBreakerForceClosed = commandProperties.CircuitBreakerForceClosed.Get(), propertyValue_circuitBreakerForceOpen = commandProperties.CircuitBreakerForceOpen.Get(), propertyValue_circuitBreakerRequestVolumeThreshold = commandProperties.CircuitBreakerRequestVolumeThreshold.Get(), propertyValue_circuitBreakerSleepWindowInMilliseconds = (int)commandProperties.CircuitBreakerSleepWindow.Get().TotalMilliseconds, propertyValue_executionIsolationSemaphoreMaxConcurrentRequests = 1000, propertyValue_executionIsolationStrategy = TurbineStrategySemaphore, propertyValue_executionIsolationThreadTimeoutInMilliseconds = (int)operation.HystrixCommand.GetExecutionTimeout().TotalMilliseconds, propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests = 0, propertyValue_metricsRollingStatisticalWindowInMilliseconds = commandProperties.MetricsRollingStatisticalWindowInMilliseconds.Get(), currentConcurrentExecutionCount = commandMetrics.CurrentConcurrentExecutionCount }; result.Add(hystrixCommandInfo); } } return(result); }
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); }