Skip to content

Cleanup op and description mapping #4560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,3 @@ class SDKInfo(TypedDict):
)

HttpStatusCodeRange = Union[int, Container[int]]

OtelExtractedSpanData = tuple[str, str, Optional[str], Optional[int], Optional[str]]
3 changes: 3 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ class OP:
HTTP_CLIENT = "http.client"
HTTP_CLIENT_STREAM = "http.client.stream"
HTTP_SERVER = "http.server"
HTTP = "http"
MESSAGE = "message"
MIDDLEWARE_DJANGO = "middleware.django"
MIDDLEWARE_LITESTAR = "middleware.litestar"
MIDDLEWARE_LITESTAR_RECEIVE = "middleware.litestar.receive"
Expand Down Expand Up @@ -705,6 +707,7 @@ class OP:
QUEUE_TASK_HUEY = "queue.task.huey"
QUEUE_SUBMIT_RAY = "queue.submit.ray"
QUEUE_TASK_RAY = "queue.task.ray"
RPC = "rpc"
SUBPROCESS = "subprocess"
SUBPROCESS_WAIT = "subprocess.wait"
SUBPROCESS_COMMUNICATE = "subprocess.communicate"
Expand Down
20 changes: 10 additions & 10 deletions sentry_sdk/opentelemetry/span_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,16 @@ def _root_span_to_transaction_event(self, span: ReadableSpan) -> Optional[Event]
if profile_context:
contexts["profile"] = profile_context

(_, description, _, http_status, _) = span_data

if http_status:
contexts["response"] = {"status_code": http_status}
if span_data.http_status:
contexts["response"] = {"status_code": span_data.http_status}

if span.resource.attributes:
contexts[OTEL_SENTRY_CONTEXT] = {"resource": dict(span.resource.attributes)}

event.update(
{
"type": "transaction",
"transaction": transaction_name or description,
"transaction": transaction_name or span_data.description,
"transaction_info": {"source": transaction_source or "custom"},
"contexts": contexts,
}
Expand All @@ -257,19 +255,21 @@ def _span_to_json(self, span: ReadableSpan) -> Optional[dict[str, Any]]:
span_id = format_span_id(span.context.span_id)
parent_span_id = format_span_id(span.parent.span_id) if span.parent else None

(op, description, status, _, origin) = extract_span_data(span)
span_data = extract_span_data(span)

span_json.update(
{
"trace_id": trace_id,
"span_id": span_id,
"op": op,
"description": description,
"status": status,
"origin": origin or DEFAULT_SPAN_ORIGIN,
"description": span_data.description,
"origin": span_data.origin or DEFAULT_SPAN_ORIGIN,
}
)

if span_data.op:
span_json["op"] = span_data.op
if span_data.status:
span_json["status"] = span_data.status
if parent_span_id:
span_json["parent_span_id"] = parent_span_id

Expand Down
Loading
Loading