Skip to content

Commit a524654

Browse files
authored
fix(otel): use http/grpc status over span status (#6879)
Prioritize http/grpc status over span status when we generate a status for a sentry span. This is because they are more thorough then OpenTelemetry's span status values.
1 parent 868c20b commit a524654

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

packages/opentelemetry-node/src/utils/map-otel-status.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ const canonicalCodesGrpcMap: Record<string, SentryStatus> = {
4646
export function mapOtelStatus(otelSpan: OtelSpan): SentryStatus {
4747
const { status, attributes } = otelSpan;
4848

49-
const statusCode = status.code;
50-
51-
if (statusCode < 0 || statusCode > 2) {
52-
return 'unknown_error';
53-
}
54-
55-
if (statusCode === 0 || statusCode === 1) {
56-
return 'ok';
57-
}
58-
5949
const httpCode = attributes[SemanticAttributes.HTTP_STATUS_CODE];
6050
const grpcCode = attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];
6151

@@ -74,5 +64,10 @@ export function mapOtelStatus(otelSpan: OtelSpan): SentryStatus {
7464
}
7565
}
7666

67+
const statusCode = status.code;
68+
if (statusCode === 0 || statusCode === 1) {
69+
return 'ok';
70+
}
71+
7772
return 'unknown_error';
7873
}

0 commit comments

Comments
 (0)