How to use the @opentelemetry/types.CanonicalCode.PERMISSION_DENIED function in @opentelemetry/types

To help you get started, we’ve selected a few @opentelemetry/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-js / packages / opentelemetry-plugin-http / src / utils.ts View on Github external
statusCode: number
): Omit => {
  if (statusCode < 200 || statusCode > 504) {
    return { code: CanonicalCode.UNKNOWN };
  } else if (statusCode >= 200 && statusCode < 400) {
    return { code: CanonicalCode.OK };
  } else {
    switch (statusCode) {
      case 400:
        return { code: CanonicalCode.INVALID_ARGUMENT };
      case 504:
        return { code: CanonicalCode.DEADLINE_EXCEEDED };
      case 404:
        return { code: CanonicalCode.NOT_FOUND };
      case 403:
        return { code: CanonicalCode.PERMISSION_DENIED };
      case 401:
        return { code: CanonicalCode.UNAUTHENTICATED };
      case 429:
        return { code: CanonicalCode.RESOURCE_EXHAUSTED };
      case 501:
        return { code: CanonicalCode.UNIMPLEMENTED };
      case 503:
        return { code: CanonicalCode.UNAVAILABLE };
      default:
        return { code: CanonicalCode.UNKNOWN };
    }
  }
};
github Azure / azure-sdk-for-js / sdk / appconfiguration / app-configuration / src / internal / tracingHelpers.ts View on Github external
static getCanonicalCode(err: Error) {
    if (Spanner.isRestError(err)) {
      switch (err.statusCode) {
        case 401:
          return CanonicalCode.PERMISSION_DENIED;
        case 404:
          return CanonicalCode.NOT_FOUND;
        case 412:
          return CanonicalCode.FAILED_PRECONDITION;
      }
    }

    return CanonicalCode.UNKNOWN;
  }