Skip to content

Commit 6978006

Browse files
committed
Cleaner http op logic
1 parent eaf30e5 commit 6978006

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

sentry_sdk/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ class OP:
674674
HTTP_CLIENT = "http.client"
675675
HTTP_CLIENT_STREAM = "http.client.stream"
676676
HTTP_SERVER = "http.server"
677+
HTTP = "http"
677678
MESSAGE = "message"
678679
MIDDLEWARE_DJANGO = "middleware.django"
679680
MIDDLEWARE_LITESTAR = "middleware.litestar"

sentry_sdk/opentelemetry/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ def infer_op(span: ReadableSpan) -> Optional[str]:
160160
return None
161161

162162
if SpanAttributes.HTTP_METHOD in span.attributes:
163-
op = "http"
164163
if span.kind == SpanKind.SERVER:
165-
op += ".server"
164+
return OP.HTTP_SERVER
166165
elif span.kind == SpanKind.CLIENT:
167-
op += ".client"
168-
return op
166+
return OP.HTTP_CLIENT
167+
else:
168+
return OP.HTTP
169169
elif SpanAttributes.DB_SYSTEM in span.attributes:
170170
return OP.DB
171171
elif SpanAttributes.RPC_SERVICE in span.attributes:

0 commit comments

Comments
 (0)