Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions packages/core/src/tracing/spanstatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const SPAN_STATUS_ERROR = 2;
* Converts a HTTP status code into a sentry status with a message.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
* @returns The span status or internal_error.
*/
// https://develop.sentry.dev/sdk/event-payloads/span/
export function getSpanStatusFromHttpCode(httpStatus: number): SpanStatus {
Expand Down Expand Up @@ -51,7 +51,7 @@ export function getSpanStatusFromHttpCode(httpStatus: number): SpanStatus {
}
}

return { code: SPAN_STATUS_ERROR, message: 'unknown_error' };
return { code: SPAN_STATUS_ERROR, message: 'internal_error' };
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/anthropic-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function addPrivateRequestAttributes(span: Span, params: Record<string, unknown>
*/
function handleResponseError(span: Span, response: AnthropicAiResponse): void {
if (response.error) {
span.setStatus({ code: SPAN_STATUS_ERROR, message: response.error.type || 'unknown_error' });
span.setStatus({ code: SPAN_STATUS_ERROR, message: response.error.type || 'internal_error' });

captureException(response.error, {
mechanism: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/anthropic-ai/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function isErrorEvent(event: AnthropicAiStreamingEvent, span: Span): boolean {
// If the event is an error, set the span status and capture the error
// These error events are not rejected by the API by default, but are sent as metadata of the response
if (event.type === 'error') {
span.setStatus({ code: SPAN_STATUS_ERROR, message: event.error?.type ?? 'unknown_error' });
span.setStatus({ code: SPAN_STATUS_ERROR, message: event.error?.type ?? 'internal_error' });
captureException(event.error, {
mechanism: {
handled: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/spanUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export function getStatusMessage(status: SpanStatus | undefined): string | undef
return 'ok';
}

return status.message || 'unknown_error';
return status.message || 'internal_error';
}

const CHILD_SPANS_FIELD = '_sentryChildSpans';
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/lib/tracing/spanstatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ describe('setHttpStatus', () => {
expect(data).toMatchObject({ 'http.response.status_code': code });
});

it("doesn't set the status for an unknown http status code", () => {
it('defaults to internal_error', () => {
const span = new SentrySpan({ name: 'test' });

setHttpStatus(span, 600);

const { status: spanStatus, data } = spanToJSON(span);

expect(spanStatus).toBeUndefined();
expect(spanStatus).toBe('internal_error');
expect(data).toMatchObject({ 'http.response.status_code': 600 });
});
});
2 changes: 1 addition & 1 deletion packages/node/src/integrations/tracing/postgresjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsIns
code: SPAN_STATUS_ERROR,
// This message is the error message from the rejectArgs, when available
// e.g "relation 'User' does not exist"
message: rejectArgs?.[0]?.message || 'unknown_error',
message: rejectArgs?.[0]?.message || 'internal_error',
});

const result = Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);
Expand Down
Loading