io.opencensus.trace.Status.isOk()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中io.opencensus.trace.Status.isOk()方法的一些代码示例,展示了Status.isOk()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.isOk()方法的具体详情如下:
包路径:io.opencensus.trace.Status
类名称:Status
方法名:isOk

Status.isOk介绍

[英]Returns true if this Status is OK, i.e., not an error.
[中]如果此状态正常,即不是错误,则返回true。

代码示例

代码示例来源:origin: census-instrumentation/opencensus-java

sb.append("\"name\":\"").append(toSpanName(span)).append("\",");
sb.append("\"type\":\"").append(toSpanType(span)).append('"');
if (!status.isOk()) {
 sb.append(",\"error\":").append("true");

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void status_Ok() {
 assertThat(Status.OK.getCanonicalCode()).isEqualTo(Status.CanonicalCode.OK);
 assertThat(Status.OK.getDescription()).isNull();
 assertThat(Status.OK.isOk()).isTrue();
}

代码示例来源:origin: census-instrumentation/opencensus-java

private void considerForSampling(RecordEventsSpanImpl span) {
 Status status = span.getStatus();
 // Null status means running Span, this should not happen in production, but the library
 // should not crash because of this.
 if (status != null) {
  Bucket bucket =
    status.isOk()
      ? getLatencyBucket(span.getLatencyNs())
      : getErrorBucket(status.getCanonicalCode());
  // If unable to find the bucket, ignore this Span.
  if (bucket != null) {
   bucket.considerForSampling(span);
  }
 }
}

代码示例来源:origin: io.opencensus/opencensus-impl-core

private void considerForSampling(RecordEventsSpanImpl span) {
 Status status = span.getStatus();
 // Null status means running Span, this should not happen in production, but the library
 // should not crash because of this.
 if (status != null) {
  Bucket bucket =
    status.isOk()
      ? getLatencyBucket(span.getLatencyNs())
      : getErrorBucket(status.getCanonicalCode());
  // If unable to find the bucket, ignore this Span.
  if (bucket != null) {
   bucket.considerForSampling(span);
  }
 }
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void createStatus_WithDescription() {
 Status status = Status.UNKNOWN.withDescription("This is an error.");
 assertThat(status.getCanonicalCode()).isEqualTo(Status.CanonicalCode.UNKNOWN);
 assertThat(status.getDescription()).isEqualTo("This is an error.");
 assertThat(status.isOk()).isFalse();
}

相关文章