77from typing import List , Optional
88from unittest .mock import Mock
99
10- from sentry_sdk import start_span , start_transaction
10+ from sentry_sdk import start_span
1111from sentry_sdk .consts import OP
1212from sentry_sdk .integrations .grpc import GRPCIntegration
1313from tests .conftest import ApproxDict
@@ -41,7 +41,7 @@ def _tear_down(server: grpc.Server):
4141
4242
4343@pytest .mark .forked
44- def test_grpc_server_starts_transaction (sentry_init , capture_events_forksafe ):
44+ def test_grpc_server_starts_root_span (sentry_init , capture_events_forksafe ):
4545 sentry_init (traces_sample_rate = 1.0 , integrations = [GRPCIntegration ()])
4646 events = capture_events_forksafe ()
4747
@@ -99,7 +99,7 @@ def test_grpc_server_other_interceptors(sentry_init, capture_events_forksafe):
9999
100100
101101@pytest .mark .forked
102- def test_grpc_server_continues_transaction (sentry_init , capture_events_forksafe ):
102+ def test_grpc_server_continues_trace (sentry_init , capture_events_forksafe ):
103103 sentry_init (traces_sample_rate = 1.0 , integrations = [GRPCIntegration ()])
104104 events = capture_events_forksafe ()
105105
@@ -108,20 +108,20 @@ def test_grpc_server_continues_transaction(sentry_init, capture_events_forksafe)
108108 with grpc .insecure_channel ("localhost:{}" .format (PORT )) as channel :
109109 stub = gRPCTestServiceStub (channel )
110110
111- with start_transaction () as transaction :
111+ with start_span () as root_span :
112112 metadata = (
113113 (
114114 "baggage" ,
115115 "sentry-trace_id={trace_id},sentry-environment=test,"
116116 "sentry-transaction=test-transaction,sentry-sample_rate=1.0" .format (
117- trace_id = transaction .trace_id
117+ trace_id = root_span .trace_id
118118 ),
119119 ),
120120 (
121121 "sentry-trace" ,
122122 "{trace_id}-{parent_span_id}-{sampled}" .format (
123- trace_id = transaction .trace_id ,
124- parent_span_id = transaction .span_id ,
123+ trace_id = root_span .trace_id ,
124+ parent_span_id = root_span .span_id ,
125125 sampled = 1 ,
126126 ),
127127 ),
@@ -139,7 +139,7 @@ def test_grpc_server_continues_transaction(sentry_init, capture_events_forksafe)
139139 "source" : "custom" ,
140140 }
141141 assert event ["contexts" ]["trace" ]["op" ] == OP .GRPC_SERVER
142- assert event ["contexts" ]["trace" ]["trace_id" ] == transaction .trace_id
142+ assert event ["contexts" ]["trace" ]["trace_id" ] == root_span .trace_id
143143 assert span ["op" ] == "test"
144144
145145
@@ -153,17 +153,17 @@ def test_grpc_client_starts_span(sentry_init, capture_events_forksafe):
153153 with grpc .insecure_channel ("localhost:{}" .format (PORT )) as channel :
154154 stub = gRPCTestServiceStub (channel )
155155
156- with start_transaction ():
156+ with start_span ():
157157 stub .TestServe (gRPCTestMessage (text = "test" ))
158158
159159 _tear_down (server = server )
160160
161161 events .write_file .close ()
162162 events .read_event ()
163- local_transaction = events .read_event ()
164- span = local_transaction ["spans" ][0 ]
163+ local_root_span = events .read_event ()
164+ span = local_root_span ["spans" ][0 ]
165165
166- assert len (local_transaction ["spans" ]) == 1
166+ assert len (local_root_span ["spans" ]) == 1
167167 assert span ["op" ] == OP .GRPC_CLIENT
168168 assert (
169169 span ["description" ]
@@ -188,16 +188,16 @@ def test_grpc_client_unary_stream_starts_span(sentry_init, capture_events_forksa
188188 with grpc .insecure_channel ("localhost:{}" .format (PORT )) as channel :
189189 stub = gRPCTestServiceStub (channel )
190190
191- with start_transaction ():
191+ with start_span ():
192192 [el for el in stub .TestUnaryStream (gRPCTestMessage (text = "test" ))]
193193
194194 _tear_down (server = server )
195195
196196 events .write_file .close ()
197- local_transaction = events .read_event ()
198- span = local_transaction ["spans" ][0 ]
197+ local_root_span = events .read_event ()
198+ span = local_root_span ["spans" ][0 ]
199199
200- assert len (local_transaction ["spans" ]) == 1
200+ assert len (local_root_span ["spans" ]) == 1
201201 assert span ["op" ] == OP .GRPC_CLIENT
202202 assert (
203203 span ["description" ]
@@ -233,7 +233,7 @@ def test_grpc_client_other_interceptor(sentry_init, capture_events_forksafe):
233233 channel = grpc .intercept_channel (channel , MockClientInterceptor ())
234234 stub = gRPCTestServiceStub (channel )
235235
236- with start_transaction ():
236+ with start_span ():
237237 stub .TestServe (gRPCTestMessage (text = "test" ))
238238
239239 _tear_down (server = server )
@@ -242,10 +242,10 @@ def test_grpc_client_other_interceptor(sentry_init, capture_events_forksafe):
242242
243243 events .write_file .close ()
244244 events .read_event ()
245- local_transaction = events .read_event ()
246- span = local_transaction ["spans" ][0 ]
245+ local_root_span = events .read_event ()
246+ span = local_root_span ["spans" ][0 ]
247247
248- assert len (local_transaction ["spans" ]) == 1
248+ assert len (local_root_span ["spans" ]) == 1
249249 assert span ["op" ] == OP .GRPC_CLIENT
250250 assert (
251251 span ["description" ]
@@ -272,18 +272,18 @@ def test_grpc_client_and_servers_interceptors_integration(
272272 with grpc .insecure_channel ("localhost:{}" .format (PORT )) as channel :
273273 stub = gRPCTestServiceStub (channel )
274274
275- with start_transaction ():
275+ with start_span ():
276276 stub .TestServe (gRPCTestMessage (text = "test" ))
277277
278278 _tear_down (server = server )
279279
280280 events .write_file .close ()
281- server_transaction = events .read_event ()
282- local_transaction = events .read_event ()
281+ server_root_span = events .read_event ()
282+ local_root_span = events .read_event ()
283283
284284 assert (
285- server_transaction ["contexts" ]["trace" ]["trace_id" ]
286- == local_transaction ["contexts" ]["trace" ]["trace_id" ]
285+ server_root_span ["contexts" ]["trace" ]["trace_id" ]
286+ == local_root_span ["contexts" ]["trace" ]["trace_id" ]
287287 )
288288
289289
@@ -328,26 +328,23 @@ def test_span_origin(sentry_init, capture_events_forksafe):
328328 with grpc .insecure_channel ("localhost:{}" .format (PORT )) as channel :
329329 stub = gRPCTestServiceStub (channel )
330330
331- with start_transaction (name = "custom_transaction " ):
331+ with start_span (name = "custom_root " ):
332332 stub .TestServe (gRPCTestMessage (text = "test" ))
333333
334334 _tear_down (server = server )
335335
336336 events .write_file .close ()
337337
338- transaction_from_integration = events .read_event ()
339- custom_transaction = events .read_event ()
338+ root_span_from_integration = events .read_event ()
339+ custom_root_span = events .read_event ()
340340
341+ assert root_span_from_integration ["contexts" ]["trace" ]["origin" ] == "auto.grpc.grpc"
341342 assert (
342- transaction_from_integration ["contexts" ]["trace" ]["origin" ] == "auto.grpc.grpc"
343- )
344- assert (
345- transaction_from_integration ["spans" ][0 ]["origin" ]
346- == "auto.grpc.grpc.TestService"
343+ root_span_from_integration ["spans" ][0 ]["origin" ] == "auto.grpc.grpc.TestService"
347344 ) # manually created in TestService, not the instrumentation
348345
349- assert custom_transaction ["contexts" ]["trace" ]["origin" ] == "manual"
350- assert custom_transaction ["spans" ][0 ]["origin" ] == "auto.grpc.grpc"
346+ assert custom_root_span ["contexts" ]["trace" ]["origin" ] == "manual"
347+ assert custom_root_span ["spans" ][0 ]["origin" ] == "auto.grpc.grpc"
351348
352349
353350class TestService (gRPCTestServiceServicer ):
0 commit comments