Skip to content

Commit 4b43d32

Browse files
committed
ref(boto3): Use rpc as the default span op
1 parent d22300b commit 4b43d32

11 files changed

Lines changed: 28 additions & 27 deletions

File tree

‎sentry_sdk/consts.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,7 @@ class OP:
13891389
QUEUE_TASK_RAY = "queue.task.ray"
13901390
QUEUE_TASK_DRAMATIQ = "queue.task.dramatiq"
13911391
QUEUE_SUBMIT_DJANGO = "queue.submit.django"
1392+
RPC = "rpc"
13921393
SUBPROCESS = "subprocess"
13931394
SUBPROCESS_WAIT = "subprocess.wait"
13941395
SUBPROCESS_COMMUNICATE = "subprocess.communicate"

‎sentry_sdk/integrations/boto3/_instrumentation.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _start_client_span(
169169

170170
# `sentry.op` and `sentry.origin` are set to generic defaults;
171171
# a service extension can override them with `get_span_op()` and `get_span_origin()`.
172-
span_op = OP.HTTP_CLIENT
172+
span_op = OP.RPC
173173
span_origin = ORIGIN
174174

175175
if service_ext is not None:

‎tests/integrations/boto3/test_client.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def record_client_span(request, **kwargs):
146146
if span["name"] == "S3.GetObject"
147147
and (
148148
span.get("attributes", {}).get(SPANDATA.SENTRY_ORIGIN) == ORIGIN
149-
and span.get("attributes", {}).get(SPANDATA.SENTRY_OP) == OP.HTTP_CLIENT
149+
and span.get("attributes", {}).get(SPANDATA.SENTRY_OP) == OP.RPC
150150
)
151151
]
152152
http_spans = [
@@ -231,7 +231,7 @@ def invoke():
231231
assert sentry_sdk.get_current_span() is parent
232232

233233
spans_by_op = _capture_boto3_spans_by_op(invoke, capture_items)
234-
(client_span,) = spans_by_op[OP.HTTP_CLIENT]
234+
(client_span,) = spans_by_op[OP.RPC]
235235
(stream_span,) = spans_by_op[OP.HTTP_CLIENT_STREAM]
236236
assert stream_span.get("parent_span_id") == client_span["span_id"]
237237

@@ -251,7 +251,7 @@ def test_omit_url_data_if_parsing_fails(capture_items, client_factory):
251251
)
252252

253253
parse_url.assert_called()
254-
(span,) = spans_by_op[OP.HTTP_CLIENT]
254+
(span,) = spans_by_op[OP.RPC]
255255
attributes = span.get("attributes", {})
256256
assert SPANDATA.URL_FULL not in attributes
257257
assert SPANDATA.URL_FRAGMENT not in attributes
@@ -326,7 +326,7 @@ def test_url_query_data_collection(
326326
(span,) = [
327327
item.payload
328328
for item in items
329-
if item.payload.get("attributes", {}).get(SPANDATA.SENTRY_OP) == OP.HTTP_CLIENT
329+
if item.payload.get("attributes", {}).get(SPANDATA.SENTRY_OP) == OP.RPC
330330
]
331331
attributes = span.get("attributes", {})
332332

@@ -428,7 +428,7 @@ def _capture_stubbed_client_span(
428428
)
429429
stubber.assert_no_pending_responses()
430430

431-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
431+
client_spans = spans_by_op.get(OP.RPC, [])
432432
assert len(client_spans) == 1
433433
return client_spans[0]
434434

@@ -580,7 +580,7 @@ def test_client_call_has_common_attributes(
580580

581581
assert span["name"] == span_name
582582
assert span.get("end_timestamp") is not None
583-
assert attributes[SPANDATA.SENTRY_OP] == OP.HTTP_CLIENT
583+
assert attributes[SPANDATA.SENTRY_OP] == OP.RPC
584584
assert attributes[SPANDATA.SENTRY_ORIGIN] == ORIGIN
585585
assert attributes[SPANDATA.SENTRY_KIND] == "client"
586586
assert attributes[SPANDATA.CLOUD_PROVIDER] == CLOUD_PROVIDER
@@ -651,7 +651,7 @@ def test_client_call_has_response_header_attributes(
651651
capture_items,
652652
)
653653

654-
spans = spans_by_op[OP.HTTP_CLIENT]
654+
spans = spans_by_op[OP.RPC]
655655
assert len(spans) == 1
656656
attributes = spans[0].get("attributes", {})
657657
assert attributes[SPANDATA.HTTP_STATUS_CODE] == 200
@@ -670,7 +670,7 @@ def test_retry_attempts_share_one_client_span(
670670
spans_by_op = _capture_boto3_spans_by_op(
671671
lambda: client.head_object(Bucket="bucket", Key="foo"), capture_items
672672
)
673-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
673+
client_spans = spans_by_op.get(OP.RPC, [])
674674

675675
assert len(request_span_ids) == attempt_count
676676
# all `AWSRequest` instances created during retries reference the same client span.
@@ -693,7 +693,7 @@ def attempt_failed_head_object_call():
693693
spans_by_op = _capture_boto3_spans_by_op(
694694
attempt_failed_head_object_call, capture_items
695695
)
696-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
696+
client_spans = spans_by_op.get(OP.RPC, [])
697697

698698
assert len(request_span_ids) == 2
699699
assert len(set(request_span_ids)) == 1
@@ -749,14 +749,14 @@ def invoke_failing_client_method():
749749
spans_by_op = _capture_boto3_spans_by_op(
750750
invoke_failing_client_method, capture_items
751751
)
752-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
752+
client_spans = spans_by_op.get(OP.RPC, [])
753753
_assert_one_failed_span(client_spans)
754754
attributes = client_spans[0].get("attributes", {})
755755

756756
span = client_spans[0]
757757
assert span["name"] == "S3.HeadObject"
758758
assert span.get("end_timestamp") is not None
759-
assert attributes[SPANDATA.SENTRY_OP] == OP.HTTP_CLIENT
759+
assert attributes[SPANDATA.SENTRY_OP] == OP.RPC
760760
assert attributes[SPANDATA.SENTRY_ORIGIN] == ORIGIN
761761
assert attributes[SPANDATA.SENTRY_KIND] == "client"
762762
assert attributes[SPANDATA.CLOUD_PROVIDER] == CLOUD_PROVIDER
@@ -810,7 +810,7 @@ def invoke_failing_client_method():
810810
spans_by_op = _capture_boto3_spans_by_op(
811811
invoke_failing_client_method, capture_items
812812
)
813-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
813+
client_spans = spans_by_op.get(OP.RPC, [])
814814
_assert_one_failed_span(client_spans)
815815

816816
expected_error_type = (
@@ -856,7 +856,7 @@ def invoke_client_method():
856856
stubber.add_response("head_object", original_response, api_params)
857857
spans_by_op = _capture_boto3_spans_by_op(invoke_client_method, capture_items)
858858

859-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
859+
client_spans = spans_by_op.get(OP.RPC, [])
860860
assert returned_responses == [original_response]
861861
assert returned_responses[0] is original_response
862862
if failing_instrumentation == "_get_response_attributes":
@@ -893,7 +893,7 @@ def invoke_failing_client_method():
893893
spans_by_op = _capture_boto3_spans_by_op(
894894
invoke_failing_client_method, capture_items
895895
)
896-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
896+
client_spans = spans_by_op.get(OP.RPC, [])
897897

898898
assert len(client_spans) == 1
899899
assert client_spans[0]["status"] == "error"
@@ -926,7 +926,7 @@ def invoke_client_method_and_read_body():
926926
spans_by_op = _capture_boto3_spans_by_op(
927927
invoke_client_method_and_read_body, capture_items
928928
)
929-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
929+
client_spans = spans_by_op.get(OP.RPC, [])
930930
stream_spans = spans_by_op.get(OP.HTTP_CLIENT_STREAM, [])
931931

932932
assert len(client_spans) == 1
@@ -975,7 +975,7 @@ def invoke_client_method_and_read_body():
975975
spans_by_op = _capture_boto3_spans_by_op(
976976
invoke_client_method_and_read_body, capture_items
977977
)
978-
client_spans = spans_by_op.get(OP.HTTP_CLIENT, [])
978+
client_spans = spans_by_op.get(OP.RPC, [])
979979
stream_spans = spans_by_op.get(OP.HTTP_CLIENT_STREAM, [])
980980

981981
assert len(client_spans) == 1

‎tests/integrations/boto3/test_dynamodb.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_request_attributes(
3636
lambda: getattr(client, method)(**params), capture_items
3737
)
3838

39-
(span,) = spans[OP.HTTP_CLIENT]
39+
(span,) = spans[OP.RPC]
4040
attributes = span["attributes"]
4141
if expected_resource_id is None:
4242
assert SPANDATA.CLOUD_ACCOUNT_ID not in attributes

‎tests/integrations/boto3/test_kinesis.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_request_attributes(client_factory, capture_items):
1818
capture_items,
1919
)
2020

21-
(span,) = spans[OP.HTTP_CLIENT]
21+
(span,) = spans[OP.RPC]
2222
attributes = span["attributes"]
2323
assert attributes[SPANDATA.CLOUD_ACCOUNT_ID] == "123456789012"
2424
assert attributes[SPANDATA.CLOUD_RESOURCE_ID] == stream_arn

‎tests/integrations/boto3/test_lambda.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_request_attributes(client_factory, capture_items):
1616
capture_items,
1717
)
1818

19-
(span,) = spans[OP.HTTP_CLIENT]
19+
(span,) = spans[OP.RPC]
2020
attributes = span["attributes"]
2121
assert attributes[SPANDATA.CLOUD_ACCOUNT_ID] == "123456789012"
2222
assert attributes[SPANDATA.CLOUD_RESOURCE_ID] == function_arn

‎tests/integrations/boto3/test_s3.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def _stubbed_span(client, capture_items, method, params, response):
2626
lambda: getattr(client, method)(**params), capture_items
2727
)
2828
stubber.assert_no_pending_responses()
29-
(span,) = spans[OP.HTTP_CLIENT]
29+
(span,) = spans[OP.RPC]
3030
operation = client.meta.method_to_api_mapping[method]
3131
assert span["name"] == "S3.%s" % operation
3232
assert span.get("end_timestamp") is not None
3333
attributes = span.get("attributes", {})
34-
assert attributes[SPANDATA.SENTRY_OP] == OP.HTTP_CLIENT
34+
assert attributes[SPANDATA.SENTRY_OP] == OP.RPC
3535
assert attributes[SPANDATA.SENTRY_ORIGIN] == ORIGIN
3636
assert attributes[SPANDATA.SENTRY_KIND] == "client"
3737
assert attributes[SPANDATA.CLOUD_PROVIDER] == "aws"

‎tests/integrations/boto3/test_secretsmanager.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_request_attributes(client_factory, capture_items):
2222
capture_items,
2323
)
2424

25-
(span,) = spans[OP.HTTP_CLIENT]
25+
(span,) = spans[OP.RPC]
2626
attributes = span["attributes"]
2727
assert attributes[SPANDATA.CLOUD_ACCOUNT_ID] == "123456789012"
28-
assert attributes[SPANDATA.CLOUD_RESOURCE_ID] == secret_arn
28+
assert attributes[SPANDATA.CLOUD_RESOURCE_ID] == secret_arn

‎tests/integrations/boto3/test_sns.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_request_attributes(client_factory, capture_items):
1515
lambda: client.delete_topic(**{"TopicArn": topic_arn}), capture_items
1616
)
1717

18-
(span,) = spans[OP.HTTP_CLIENT]
18+
(span,) = spans[OP.RPC]
1919
attributes = span["attributes"]
2020
assert attributes[SPANDATA.CLOUD_ACCOUNT_ID] == "123456789012"
2121
assert attributes[SPANDATA.CLOUD_RESOURCE_ID] == topic_arn

‎tests/integrations/boto3/test_sqs.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_request_attributes(client_factory, capture_items, source):
3333
lambda: getattr(client, method)(**params), capture_items
3434
)
3535

36-
(span,) = spans[OP.HTTP_CLIENT]
36+
(span,) = spans[OP.RPC]
3737
attributes = span["attributes"]
3838
assert attributes[SPANDATA.CLOUD_ACCOUNT_ID] == "123456789012"
3939
if resource_id is None:

0 commit comments

Comments
 (0)