Skip to content

Commit b577645

Browse files
committed
fix(tracing): Treat HTTP status code below 100 as UnknownError. (#4131)
1 parent 6f9aac9 commit b577645

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/tracing/src/spanstatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export namespace SpanStatus {
4646
* @returns The span status or {@link SpanStatus.UnknownError}.
4747
*/
4848
export function fromHttpCode(httpStatus: number): SpanStatus {
49-
if (httpStatus < 400) {
49+
if (httpStatus < 400 && httpStatus >= 100) {
5050
return SpanStatus.Ok;
5151
}
5252

packages/tracing/test/span.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ describe('Span', () => {
9090
expect(span.isSuccess()).toBe(true);
9191
span.setStatus(SpanStatus.PermissionDenied);
9292
expect(span.isSuccess()).toBe(false);
93+
span.setHttpStatus(0);
94+
expect(span.isSuccess()).toBe(false);
95+
span.setHttpStatus(-1);
96+
expect(span.isSuccess()).toBe(false);
97+
span.setHttpStatus(99);
98+
expect(span.isSuccess()).toBe(false);
99+
span.setHttpStatus(100);
100+
expect(span.isSuccess()).toBe(true);
93101
});
94102
});
95103

0 commit comments

Comments
 (0)