@@ -46,9 +46,10 @@ export interface Span {
46
46
47
47
/**
48
48
* Sets the status attribute on the current span
49
+ * See: {@sentry /apm SpanStatus} for possible values
49
50
* @param status http code used to set the status
50
51
*/
51
- setStatus ( status : SpanStatus ) : this;
52
+ setStatus ( status : string ) : this;
52
53
53
54
/**
54
55
* Sets the status attribute on the current span based on the http code
@@ -87,8 +88,9 @@ export interface SpanContext {
87
88
op ?: string ;
88
89
/**
89
90
* Completion status of the Span.
91
+ * See: {@sentry /apm SpanStatus} for possible values
90
92
*/
91
- status ?: SpanStatus ;
93
+ status ?: string ;
92
94
/**
93
95
* Parent Span ID
94
96
*/
@@ -119,91 +121,3 @@ export interface SpanContext {
119
121
*/
120
122
data ?: { [ key : string ] : any } ;
121
123
}
122
-
123
- /** The status of an Span. */
124
- export enum SpanStatus {
125
- /** The operation completed successfully. */
126
- Ok = 'ok' ,
127
- /** Deadline expired before operation could complete. */
128
- DeadlineExceeded = 'deadline_exceeded' ,
129
- /** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
130
- Unauthenticated = 'unauthenticated' ,
131
- /** 403 Forbidden */
132
- PermissionDenied = 'permission_denied' ,
133
- /** 404 Not Found. Some requested entity (file or directory) was not found. */
134
- NotFound = 'not_found' ,
135
- /** 429 Too Many Requests */
136
- ResourceExhausted = 'resource_exhausted' ,
137
- /** Client specified an invalid argument. 4xx. */
138
- InvalidArgument = 'invalid_argument' ,
139
- /** 501 Not Implemented */
140
- Unimplemented = 'unimplemented' ,
141
- /** 503 Service Unavailable */
142
- Unavailable = 'unavailable' ,
143
- /** Other/generic 5xx. */
144
- InternalError = 'internal_error' ,
145
- /** Unknown. Any non-standard HTTP status code. */
146
- UnknownError = 'unknown_error' ,
147
- /** The operation was cancelled (typically by the user). */
148
- Cancelled = 'cancelled' ,
149
- /** Already exists (409) */
150
- AlreadyExists = 'already_exists' ,
151
- /** Operation was rejected because the system is not in a state required for the operation's */
152
- FailedPrecondition = 'failed_precondition' ,
153
- /** The operation was aborted, typically due to a concurrency issue. */
154
- Aborted = 'aborted' ,
155
- /** Operation was attempted past the valid range. */
156
- OutOfRange = 'out_of_range' ,
157
- /** Unrecoverable data loss or corruption */
158
- DataLoss = 'data_loss' ,
159
- }
160
-
161
- // tslint:disable:no-unnecessary-qualifier no-namespace
162
- export namespace SpanStatus {
163
- /**
164
- * Converts a HTTP status code into a {@link SpanStatus}.
165
- *
166
- * @param httpStatus The HTTP response status code.
167
- * @returns The span status or {@link SpanStatus.UnknownError}.
168
- */
169
- // tslint:disable-next-line:completed-docs
170
- export function fromHttpCode ( httpStatus : number ) : SpanStatus {
171
- if ( httpStatus < 400 ) {
172
- return SpanStatus . Ok ;
173
- }
174
-
175
- if ( httpStatus >= 400 && httpStatus < 500 ) {
176
- switch ( httpStatus ) {
177
- case 401 :
178
- return SpanStatus . Unauthenticated ;
179
- case 403 :
180
- return SpanStatus . PermissionDenied ;
181
- case 404 :
182
- return SpanStatus . NotFound ;
183
- case 409 :
184
- return SpanStatus . AlreadyExists ;
185
- case 413 :
186
- return SpanStatus . FailedPrecondition ;
187
- case 429 :
188
- return SpanStatus . ResourceExhausted ;
189
- default :
190
- return SpanStatus . InvalidArgument ;
191
- }
192
- }
193
-
194
- if ( httpStatus >= 500 && httpStatus < 600 ) {
195
- switch ( httpStatus ) {
196
- case 501 :
197
- return SpanStatus . Unimplemented ;
198
- case 503 :
199
- return SpanStatus . Unavailable ;
200
- case 504 :
201
- return SpanStatus . DeadlineExceeded ;
202
- default :
203
- return SpanStatus . InternalError ;
204
- }
205
- }
206
-
207
- return SpanStatus . UnknownError ;
208
- }
209
- }
0 commit comments