Java Code Examples for io.opencensus.trace.Status#UNAVAILABLE

The following examples show how to use io.opencensus.trace.Status#UNAVAILABLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenCensusUtils.java    From heroic with Apache License 2.0 5 votes vote down vote up
static Status mapStatusCode(int status) {
    // @formatter:off
    //
    // Mapping from:
    // https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#mapping-from-http-status-codes-to-trace-status-codes
    //
    // @formatter:on
    final Status traceStatus;
    if (status < 200) {
        traceStatus = Status.UNKNOWN;
    } else if (status < 400) {
        traceStatus = Status.OK;
    } else if (status == 400) {
        traceStatus = Status.INVALID_ARGUMENT;
    } else if (status == 404) {
        traceStatus = Status.NOT_FOUND;
    } else if (status == 403) {
        traceStatus = Status.PERMISSION_DENIED;
    } else if (status == 401) {
        traceStatus = Status.UNAUTHENTICATED;
    } else if (status == 429) {
        traceStatus = Status.RESOURCE_EXHAUSTED;
    } else if (status == 501) {
        traceStatus = Status.UNIMPLEMENTED;
    } else if (status == 503) {
        traceStatus = Status.UNAVAILABLE;
    } else if (status == 504) {
        traceStatus = Status.DEADLINE_EXCEEDED;
    } else if (status < 600) {
        traceStatus = Status.INTERNAL;
    } else {
        traceStatus = Status.UNKNOWN;
    }

    return traceStatus;
}
 
Example 2
Source File: CensusTracingModule.java    From grpc-nebula-java with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
static Status convertStatus(io.grpc.Status grpcStatus) {
  Status status;
  switch (grpcStatus.getCode()) {
    case OK:
      status = Status.OK;
      break;
    case CANCELLED:
      status = Status.CANCELLED;
      break;
    case UNKNOWN:
      status = Status.UNKNOWN;
      break;
    case INVALID_ARGUMENT:
      status = Status.INVALID_ARGUMENT;
      break;
    case DEADLINE_EXCEEDED:
      status = Status.DEADLINE_EXCEEDED;
      break;
    case NOT_FOUND:
      status = Status.NOT_FOUND;
      break;
    case ALREADY_EXISTS:
      status = Status.ALREADY_EXISTS;
      break;
    case PERMISSION_DENIED:
      status = Status.PERMISSION_DENIED;
      break;
    case RESOURCE_EXHAUSTED:
      status = Status.RESOURCE_EXHAUSTED;
      break;
    case FAILED_PRECONDITION:
      status = Status.FAILED_PRECONDITION;
      break;
    case ABORTED:
      status = Status.ABORTED;
      break;
    case OUT_OF_RANGE:
      status = Status.OUT_OF_RANGE;
      break;
    case UNIMPLEMENTED:
      status = Status.UNIMPLEMENTED;
      break;
    case INTERNAL:
      status = Status.INTERNAL;
      break;
    case UNAVAILABLE:
      status = Status.UNAVAILABLE;
      break;
    case DATA_LOSS:
      status = Status.DATA_LOSS;
      break;
    case UNAUTHENTICATED:
      status = Status.UNAUTHENTICATED;
      break;
    default:
      throw new AssertionError("Unhandled status code " + grpcStatus.getCode());
  }
  if (grpcStatus.getDescription() != null) {
    status = status.withDescription(grpcStatus.getDescription());
  }
  return status;
}
 
Example 3
Source File: CensusTracingModule.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
static Status convertStatus(io.grpc.Status grpcStatus) {
  Status status;
  switch (grpcStatus.getCode()) {
    case OK:
      status = Status.OK;
      break;
    case CANCELLED:
      status = Status.CANCELLED;
      break;
    case UNKNOWN:
      status = Status.UNKNOWN;
      break;
    case INVALID_ARGUMENT:
      status = Status.INVALID_ARGUMENT;
      break;
    case DEADLINE_EXCEEDED:
      status = Status.DEADLINE_EXCEEDED;
      break;
    case NOT_FOUND:
      status = Status.NOT_FOUND;
      break;
    case ALREADY_EXISTS:
      status = Status.ALREADY_EXISTS;
      break;
    case PERMISSION_DENIED:
      status = Status.PERMISSION_DENIED;
      break;
    case RESOURCE_EXHAUSTED:
      status = Status.RESOURCE_EXHAUSTED;
      break;
    case FAILED_PRECONDITION:
      status = Status.FAILED_PRECONDITION;
      break;
    case ABORTED:
      status = Status.ABORTED;
      break;
    case OUT_OF_RANGE:
      status = Status.OUT_OF_RANGE;
      break;
    case UNIMPLEMENTED:
      status = Status.UNIMPLEMENTED;
      break;
    case INTERNAL:
      status = Status.INTERNAL;
      break;
    case UNAVAILABLE:
      status = Status.UNAVAILABLE;
      break;
    case DATA_LOSS:
      status = Status.DATA_LOSS;
      break;
    case UNAUTHENTICATED:
      status = Status.UNAUTHENTICATED;
      break;
    default:
      throw new AssertionError("Unhandled status code " + grpcStatus.getCode());
  }
  if (grpcStatus.getDescription() != null) {
    status = status.withDescription(grpcStatus.getDescription());
  }
  return status;
}