diff --git a/packages/core/src/tracing/spanstatus.ts b/packages/core/src/tracing/spanstatus.ts index 6d353ae6a326..176e201178de 100644 --- a/packages/core/src/tracing/spanstatus.ts +++ b/packages/core/src/tracing/spanstatus.ts @@ -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 { @@ -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' }; } /** diff --git a/packages/core/src/utils/anthropic-ai/index.ts b/packages/core/src/utils/anthropic-ai/index.ts index 8e77dd76b34e..0a977559ca0e 100644 --- a/packages/core/src/utils/anthropic-ai/index.ts +++ b/packages/core/src/utils/anthropic-ai/index.ts @@ -93,7 +93,7 @@ function addPrivateRequestAttributes(span: Span, params: Record */ 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: { diff --git a/packages/core/src/utils/anthropic-ai/streaming.ts b/packages/core/src/utils/anthropic-ai/streaming.ts index b542cbfda75a..86f5c25baa8a 100644 --- a/packages/core/src/utils/anthropic-ai/streaming.ts +++ b/packages/core/src/utils/anthropic-ai/streaming.ts @@ -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, diff --git a/packages/core/src/utils/spanUtils.ts b/packages/core/src/utils/spanUtils.ts index 6e7c62c7631a..d7c261ecd73c 100644 --- a/packages/core/src/utils/spanUtils.ts +++ b/packages/core/src/utils/spanUtils.ts @@ -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'; diff --git a/packages/core/test/lib/tracing/spanstatus.test.ts b/packages/core/test/lib/tracing/spanstatus.test.ts index ee6bfd59443f..109c97d567a9 100644 --- a/packages/core/test/lib/tracing/spanstatus.test.ts +++ b/packages/core/test/lib/tracing/spanstatus.test.ts @@ -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 }); }); }); diff --git a/packages/node/src/integrations/tracing/postgresjs.ts b/packages/node/src/integrations/tracing/postgresjs.ts index 1a0eae973bc6..438a63c804c6 100644 --- a/packages/node/src/integrations/tracing/postgresjs.ts +++ b/packages/node/src/integrations/tracing/postgresjs.ts @@ -128,7 +128,7 @@ export class PostgresJsInstrumentation extends InstrumentationBase