sb.append("\"name\":\"").append(toSpanName(span)).append("\","); sb.append("\"type\":\"").append(toSpanType(span)).append('"'); if (!status.isOk()) { sb.append(",\"error\":").append("true");
@Test public void status_Ok() { assertThat(Status.OK.getCanonicalCode()).isEqualTo(Status.CanonicalCode.OK); assertThat(Status.OK.getDescription()).isNull(); assertThat(Status.OK.isOk()).isTrue(); }
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); } } }
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); } } }
@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(); }