Skip to content

Commit ebc2331

Browse files
committed
compat
1 parent 28256e2 commit ebc2331

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sentry_sdk/opentelemetry/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,12 @@ def infer_status_from_attributes(span_attributes):
282282

283283
def get_http_status_code(span_attributes):
284284
# type: (Mapping[str, str | bool | int | float | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float]]) -> Optional[int]
285-
http_status = span_attributes.get(SpanAttributes.HTTP_RESPONSE_STATUS_CODE)
285+
try:
286+
http_status = span_attributes.get(SpanAttributes.HTTP_RESPONSE_STATUS_CODE)
287+
except AttributeError:
288+
# HTTP_RESPONSE_STATUS_CODE was added in 1.21, so if we're on an older
289+
# OTel version this will not work
290+
http_status = None
286291

287292
if http_status is None:
288293
# Fall back to the deprecated attribute

0 commit comments

Comments
 (0)