Skip to content

Commit b10cae6

Browse files
committed
Set level based on status code for HTTP client breadcrumbs
1 parent 5a27502 commit b10cae6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sentry_sdk/tracing_utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,20 @@ def maybe_create_breadcrumbs_from_span(scope, span):
161161
scope.add_breadcrumb(
162162
message=span.description, type="redis", category="redis", data=span._tags
163163
)
164+
164165
elif span.op == OP.HTTP_CLIENT:
165-
scope.add_breadcrumb(type="http", category="httplib", data=span._data)
166+
level = "info" # XXX is this correct?
167+
status_code = span._data.get(SPANDATA.HTTP_STATUS_CODE)
168+
if status_code:
169+
if 500 <= status_code <= 599:
170+
level = "error"
171+
elif 400 <= status_code <= 499:
172+
level = "warning"
173+
174+
scope.add_breadcrumb(
175+
type="http", category="httplib", data=span._data, level=level
176+
)
177+
166178
elif span.op == "subprocess":
167179
scope.add_breadcrumb(
168180
type="subprocess",

0 commit comments

Comments
 (0)