|
| 1 | +/** |
| 2 | + * Copyright 2019, OpenCensus Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * @fileoverview Trace related enums. These can't be directly imported from |
| 19 | + * `@opencensus/core`, because that will create a runtime dependency on it. |
| 20 | + * That is because TypeScript enums have a runtime existence, unlike interfaces. |
| 21 | + * A runtime dependency on `@opencensus/core` is not good for OpenCensus Web, |
| 22 | + * because then it would need to depend on other Node libraries. |
| 23 | + * These enums are based on @opencensus/core and the Trace protos. See: |
| 24 | + * https://github.com/census-instrumentation/opencensus-proto/blob/master/src/opencensus/proto/trace/v1/trace.proto |
| 25 | + * https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/model/types.ts#L44 |
| 26 | + */ |
| 27 | + |
| 28 | +/** |
| 29 | + * Type of link. The relationship of the current span relative to the linked |
| 30 | + * span. |
| 31 | + */ |
| 32 | +export enum LinkType { |
| 33 | + /** |
| 34 | + * The relationship of the two spans is unknown, or known but other |
| 35 | + * than parent-child. |
| 36 | + */ |
| 37 | + UNSPECIFIED = 0, |
| 38 | + /** The linked span is a child of the current span. */ |
| 39 | + CHILD_LINKED_SPAN = 1, |
| 40 | + /** The linked span is a parent of the current span. */ |
| 41 | + PARENT_LINKED_SPAN = 2, |
| 42 | +} |
| 43 | + |
| 44 | +/** |
| 45 | + * Type of span. Can be used to specify additional relationships between spans |
| 46 | + * in addition to a parent/child relationship. |
| 47 | + */ |
| 48 | +export enum SpanKind { |
| 49 | + /** Unspecified */ |
| 50 | + UNSPECIFIED = 0, |
| 51 | + /** |
| 52 | + * Indicates that the span covers server-side handling of an RPC or other |
| 53 | + * remote network request. |
| 54 | + */ |
| 55 | + SERVER = 1, |
| 56 | + /** |
| 57 | + * Indicates that the span covers the client-side wrapper around an RPC or |
| 58 | + * other remote request. |
| 59 | + */ |
| 60 | + CLIENT = 2, |
| 61 | +} |
| 62 | + |
| 63 | +/** An enumeration of canonical status codes. */ |
| 64 | +export enum CanonicalCode { |
| 65 | + /** |
| 66 | + * Not an error; returned on success |
| 67 | + */ |
| 68 | + OK = 0, |
| 69 | + /** |
| 70 | + * The operation was cancelled (typically by the caller). |
| 71 | + */ |
| 72 | + CANCELLED = 1, |
| 73 | + /** |
| 74 | + * Unknown error. An example of where this error may be returned is |
| 75 | + * if a status value received from another address space belongs to |
| 76 | + * an error-space that is not known in this address space. Also |
| 77 | + * errors raised by APIs that do not return enough error information |
| 78 | + * may be converted to this error. |
| 79 | + */ |
| 80 | + UNKNOWN = 2, |
| 81 | + /** |
| 82 | + * Client specified an invalid argument. Note that this differs |
| 83 | + * from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments |
| 84 | + * that are problematic regardless of the state of the system |
| 85 | + * (e.g., a malformed file name). |
| 86 | + */ |
| 87 | + INVALID_ARGUMENT = 3, |
| 88 | + /** |
| 89 | + * Deadline expired before operation could complete. For operations |
| 90 | + * that change the state of the system, this error may be returned |
| 91 | + * even if the operation has completed successfully. For example, a |
| 92 | + * successful response from a server could have been delayed long |
| 93 | + * enough for the deadline to expire. |
| 94 | + */ |
| 95 | + DEADLINE_EXCEEDED = 4, |
| 96 | + /** |
| 97 | + * Some requested entity (e.g., file or directory) was not found. |
| 98 | + */ |
| 99 | + NOT_FOUND = 5, |
| 100 | + /** |
| 101 | + * Some entity that we attempted to create (e.g., file or directory) |
| 102 | + * already exists. |
| 103 | + */ |
| 104 | + ALREADY_EXISTS = 6, |
| 105 | + /** |
| 106 | + * The caller does not have permission to execute the specified |
| 107 | + * operation. PERMISSION_DENIED must not be used for rejections |
| 108 | + * caused by exhausting some resource (use RESOURCE_EXHAUSTED |
| 109 | + * instead for those errors). PERMISSION_DENIED must not be |
| 110 | + * used if the caller can not be identified (use UNAUTHENTICATED |
| 111 | + * instead for those errors). |
| 112 | + */ |
| 113 | + PERMISSION_DENIED = 7, |
| 114 | + /** |
| 115 | + * Some resource has been exhausted, perhaps a per-user quota, or |
| 116 | + * perhaps the entire file system is out of space. |
| 117 | + */ |
| 118 | + RESOURCE_EXHAUSTED = 8, |
| 119 | + /** |
| 120 | + * Operation was rejected because the system is not in a state |
| 121 | + * required for the operation's execution. For example, directory |
| 122 | + * to be deleted may be non-empty, an rmdir operation is applied to |
| 123 | + * a non-directory, etc. |
| 124 | + * |
| 125 | + * A litmus test that may help a service implementor in deciding |
| 126 | + * between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: |
| 127 | + * |
| 128 | + * - Use UNAVAILABLE if the client can retry just the failing call. |
| 129 | + * - Use ABORTED if the client should retry at a higher-level |
| 130 | + * (e.g., restarting a read-modify-write sequence). |
| 131 | + * - Use FAILED_PRECONDITION if the client should not retry until |
| 132 | + * the system state has been explicitly fixed. E.g., if an "rmdir" |
| 133 | + * fails because the directory is non-empty, FAILED_PRECONDITION |
| 134 | + * should be returned since the client should not retry unless |
| 135 | + * they have first fixed up the directory by deleting files from it. |
| 136 | + * - Use FAILED_PRECONDITION if the client performs conditional |
| 137 | + * REST Get/Update/Delete on a resource and the resource on the |
| 138 | + * server does not match the condition. E.g., conflicting |
| 139 | + * read-modify-write on the same resource. |
| 140 | + */ |
| 141 | + FAILED_PRECONDITION = 9, |
| 142 | + /** |
| 143 | + * The operation was aborted, typically due to a concurrency issue |
| 144 | + * like sequencer check failures, transaction aborts, etc. |
| 145 | + * |
| 146 | + * See litmus test above for deciding between FAILED_PRECONDITION, |
| 147 | + * ABORTED, and UNAVAILABLE. |
| 148 | + */ |
| 149 | + ABORTED = 10, |
| 150 | + /** |
| 151 | + * Operation was attempted past the valid range. E.g., seeking or |
| 152 | + * reading past end of file. |
| 153 | + * |
| 154 | + * Unlike INVALID_ARGUMENT, this error indicates a problem that may |
| 155 | + * be fixed if the system state changes. For example, a 32-bit file |
| 156 | + * system will generate INVALID_ARGUMENT if asked to read at an |
| 157 | + * offset that is not in the range [0,2^32-1], but it will generate |
| 158 | + * OUT_OF_RANGE if asked to read from an offset past the current |
| 159 | + * file size. |
| 160 | + * |
| 161 | + * There is a fair bit of overlap between FAILED_PRECONDITION and |
| 162 | + * OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific |
| 163 | + * error) when it applies so that callers who are iterating through |
| 164 | + * a space can easily look for an OUT_OF_RANGE error to detect when |
| 165 | + * they are done. |
| 166 | + */ |
| 167 | + OUT_OF_RANGE = 11, |
| 168 | + /** |
| 169 | + * Operation is not implemented or not supported/enabled in this service. |
| 170 | + */ |
| 171 | + UNIMPLEMENTED = 12, |
| 172 | + /** |
| 173 | + * Internal errors. Means some invariants expected by underlying |
| 174 | + * system has been broken. If you see one of these errors, |
| 175 | + * something is very broken. |
| 176 | + */ |
| 177 | + INTERNAL = 13, |
| 178 | + /** |
| 179 | + * The service is currently unavailable. This is a most likely a |
| 180 | + * transient condition and may be corrected by retrying with |
| 181 | + * a backoff. |
| 182 | + * |
| 183 | + * See litmus test above for deciding between FAILED_PRECONDITION, |
| 184 | + * ABORTED, and UNAVAILABLE. |
| 185 | + */ |
| 186 | + UNAVAILABLE = 14, |
| 187 | + /** |
| 188 | + * Unrecoverable data loss or corruption. |
| 189 | + */ |
| 190 | + DATA_LOSS = 15, |
| 191 | + /** |
| 192 | + * The request does not have valid authentication credentials for the |
| 193 | + * operation. |
| 194 | + */ |
| 195 | + UNAUTHENTICATED = 16, |
| 196 | +} |
| 197 | + |
| 198 | +/** An event describing a message sent/received between Spans. */ |
| 199 | +export enum MessageEventType { |
| 200 | + /** Unknown event type. */ |
| 201 | + UNSPECIFIED = 0, |
| 202 | + /** Indicates a sent message. */ |
| 203 | + SENT = 1, |
| 204 | + /** Indicates a received message. */ |
| 205 | + RECEIVED = 2, |
| 206 | +} |
0 commit comments