本文整理汇总了C#中JsonWriter.writeBooleanField方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.writeBooleanField方法的具体用法?C# JsonWriter.writeBooleanField怎么用?C# JsonWriter.writeBooleanField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.writeBooleanField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCommandJson
private String GetCommandJson(CommandMetrics commandMetrics)
{
var circuitBreaker = CircuitBreakerFactory.GetInstance(commandMetrics.CommandName);
var sb = new StringBuilder(1024);
StringWriter sw = new StringWriter(sb, CultureInfo.InvariantCulture);
var json = new JsonWriter(sw);
json.writeStartObject();
json.writeStringField("type", "HystrixCommand");
json.writeStringField("name", commandMetrics.CommandName);
// json.writeStringField("group", commandMetrics.CommandName);
json.writeNumberField("currentTime", DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond); // TODO check this
// circuit breaker
if (circuitBreaker == null)
{
// circuit breaker is disabled and thus never open
json.writeBooleanField("isCircuitBreakerOpen", false);
}
else
{
json.writeBooleanField("isCircuitBreakerOpen", circuitBreaker.IsOpen());
}
HealthCounts healthCounts = commandMetrics.GetHealthCounts();
json.writeNumberField("errorPercentage", healthCounts.ErrorPercentage);
json.writeNumberField("errorCount", healthCounts.ErrorCount);
json.writeNumberField("requestCount", healthCounts.TotalRequests);
// rolling counters
json.writeNumberField("rollingCountBadRequests", commandMetrics.GetRollingCount(RollingNumberEvent.BAD_REQUEST));
// json.writeNumberField("rollingCountCollapsedRequests", commandMetrics.GetRollingCount(RollingNumberEvent.COLLAPSED));
//json.writeNumberField("rollingCountEmit", commandMetrics.GetRollingCount(RollingNumberEvent.EMIT));
json.writeNumberField("rollingCountExceptionsThrown", commandMetrics.GetRollingCount(RollingNumberEvent.EXCEPTION_THROWN));
json.writeNumberField("rollingCountFailure", commandMetrics.GetRollingCount(RollingNumberEvent.FAILURE));
//json.writeNumberField("rollingCountEmit", commandMetrics.GetRollingCount(RollingNumberEvent.FALLBACK_EMIT));
json.writeNumberField("rollingCountFallbackFailure", commandMetrics.GetRollingCount(RollingNumberEvent.FALLBACK_FAILURE));
json.writeNumberField("rollingCountFallbackRejection", commandMetrics.GetRollingCount(RollingNumberEvent.FALLBACK_REJECTION));
json.writeNumberField("rollingCountFallbackSuccess", commandMetrics.GetRollingCount(RollingNumberEvent.FALLBACK_SUCCESS));
json.writeNumberField("rollingCountResponsesFromCache", commandMetrics.GetRollingCount(RollingNumberEvent.RESPONSE_FROM_CACHE));
json.writeNumberField("rollingCountSemaphoreRejected", commandMetrics.GetRollingCount(RollingNumberEvent.SEMAPHORE_REJECTED));
json.writeNumberField("rollingCountShortCircuited", commandMetrics.GetRollingCount(RollingNumberEvent.SHORT_CIRCUITED));
json.writeNumberField("rollingCountSuccess", commandMetrics.GetRollingCount(RollingNumberEvent.SUCCESS));
json.writeNumberField("rollingCountThreadPoolRejected", commandMetrics.GetRollingCount(RollingNumberEvent.THREAD_POOL_REJECTED));
json.writeNumberField("rollingCountTimeout", commandMetrics.GetRollingCount(RollingNumberEvent.TIMEOUT));
json.writeNumberField("currentConcurrentExecutionCount", commandMetrics.CurrentConcurrentExecutionCount);
json.writeNumberField("rollingMaxConcurrentExecutionCount", commandMetrics.GetRollingMaxConcurrentExecutions());
// latency percentiles
json.writeNumberField("latencyExecute_mean", commandMetrics.GetExecutionTimeMean());
json.writeObjectFieldStart("latencyExecute");
json.writeNumberField("0", commandMetrics.GetExecutionTimePercentile(0));
json.writeNumberField("25", commandMetrics.GetExecutionTimePercentile(25));
json.writeNumberField("50", commandMetrics.GetExecutionTimePercentile(50));
json.writeNumberField("75", commandMetrics.GetExecutionTimePercentile(75));
json.writeNumberField("90", commandMetrics.GetExecutionTimePercentile(90));
json.writeNumberField("95", commandMetrics.GetExecutionTimePercentile(95));
json.writeNumberField("99", commandMetrics.GetExecutionTimePercentile(99));
json.writeNumberField("99.5", commandMetrics.GetExecutionTimePercentile(99.5));
json.writeNumberField("100", commandMetrics.GetExecutionTimePercentile(100));
json.writeEndObject();
//
json.writeNumberField("latencyTotal_mean", commandMetrics.GetTotalTimeMean());
json.writeObjectFieldStart("latencyTotal");
json.writeNumberField("0", commandMetrics.GetTotalTimePercentile(0));
json.writeNumberField("25", commandMetrics.GetTotalTimePercentile(25));
json.writeNumberField("50", commandMetrics.GetTotalTimePercentile(50));
json.writeNumberField("75", commandMetrics.GetTotalTimePercentile(75));
json.writeNumberField("90", commandMetrics.GetTotalTimePercentile(90));
json.writeNumberField("95", commandMetrics.GetTotalTimePercentile(95));
json.writeNumberField("99", commandMetrics.GetTotalTimePercentile(99));
json.writeNumberField("99.5", commandMetrics.GetTotalTimePercentile(99.5));
json.writeNumberField("100", commandMetrics.GetTotalTimePercentile(100));
json.writeEndObject();
// property values for reporting what is actually seen by the command rather than what was set somewhere
var commandProperties = commandMetrics.Properties;
json.writeNumberField("propertyValue_circuitBreakerRequestVolumeThreshold", commandProperties.CircuitBreakerRequestVolumeThreshold.Get());
json.writeNumberField("propertyValue_circuitBreakerSleepWindowInMilliseconds", commandProperties.CircuitBreakerSleepWindowInMilliseconds.Get());
json.writeNumberField("propertyValue_circuitBreakerErrorThresholdPercentage", commandProperties.CircuitBreakerErrorThresholdPercentage.Get());
json.writeBooleanField("propertyValue_circuitBreakerForceOpen", commandProperties.CircuitBreakerForceOpen.Get());
json.writeBooleanField("propertyValue_circuitBreakerForceClosed", commandProperties.CircuitBreakerForceClosed.Get());
json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.CircuitBreakerEnabled.Get());
//json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.ExecutionIsolationStrategy().get().name());
//json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.ExecutionTimeoutInMilliseconds().Get());
json.writeNumberField("propertyValue_executionTimeoutInMilliseconds", commandProperties.ExecutionTimeoutInMilliseconds.Get());
//json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get());
//json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get());
json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.ExecutionIsolationSemaphoreMaxConcurrentRequests.Get());
json.writeNumberField("propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests", commandProperties.FallbackIsolationSemaphoreMaxConcurrentRequests.Get());
json.writeNumberField("propertyValue_metricsRollingStatisticalWindowInMilliseconds", commandProperties.MetricsRollingStatisticalWindowInMilliseconds.Get());
//json.writeBooleanField("propertyValue_requestCacheEnabled", commandProperties.requestCacheEnabled().get());
//json.writeBooleanField("propertyValue_requestLogEnabled", commandProperties.requestLogEnabled().get());
json.writeNumberField("reportingHosts", 1); // this will get summed across all instances in a cluster
//.........这里部分代码省略.........