Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add unit test
  • Loading branch information
mydea committed Jun 12, 2024
commit 925c8443656ad182b2b9719a1df120b8683e61a4
13 changes: 13 additions & 0 deletions packages/opentelemetry/test/utils/mapStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ describe('mapStatus', () => {
expect(mapStatus(span)).toEqual({ code: SPAN_STATUS_ERROR, message: 'invalid_argument' });
});

it('returns error status when span already has error status without message', () => {
const span = createSpan();
span.setStatus({ code: 2 }); // ERROR
expect(mapStatus(span)).toEqual({ code: SPAN_STATUS_ERROR, message: 'unknown_error' });
});

it('infers error status form attributes when span already has error status without message', () => {
const span = createSpan();
span.setAttribute(SEMATTRS_HTTP_STATUS_CODE, 500);
span.setStatus({ code: 2 }); // ERROR
expect(mapStatus(span)).toEqual({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
});

it('returns unknown error status when code is unknown', () => {
const span = createSpan();
span.setStatus({ code: -1 as 0 });
Expand Down