@@ -77,42 +77,42 @@ def example_task():
7777
7878 return sentry_sdk .get_client ().transport .envelopes
7979
80- with sentry_sdk .start_transaction (op = "task " , name = "ray test transaction " ):
80+ with sentry_sdk .start_span (op = "test " , name = "ray client root span " ):
8181 worker_envelopes = ray .get (example_task .remote ())
8282
8383 client_envelope = sentry_sdk .get_client ().transport .envelopes [0 ]
84- client_transaction = client_envelope .get_transaction_event ()
85- assert client_transaction ["transaction" ] == "ray test transaction "
86- assert client_transaction ["transaction_info" ] == {"source" : "custom" }
84+ client_root_span = client_envelope .get_transaction_event ()
85+ assert client_root_span ["transaction" ] == "ray client root span "
86+ assert client_root_span ["transaction_info" ] == {"source" : "custom" }
8787
8888 worker_envelope = worker_envelopes [0 ]
89- worker_transaction = worker_envelope .get_transaction_event ()
89+ worker_root_span = worker_envelope .get_transaction_event ()
9090 assert (
91- worker_transaction ["transaction" ]
91+ worker_root_span ["transaction" ]
9292 == "tests.integrations.ray.test_ray.test_tracing_in_ray_tasks.<locals>.example_task"
9393 )
94- assert worker_transaction ["transaction_info" ] == {"source" : "task" }
94+ assert worker_root_span ["transaction_info" ] == {"source" : "task" }
9595
96- (span ,) = client_transaction ["spans" ]
96+ (span ,) = client_root_span ["spans" ]
9797 assert span ["op" ] == "queue.submit.ray"
9898 assert span ["origin" ] == "auto.queue.ray"
9999 assert (
100100 span ["description" ]
101101 == "tests.integrations.ray.test_ray.test_tracing_in_ray_tasks.<locals>.example_task"
102102 )
103- assert span ["parent_span_id" ] == client_transaction ["contexts" ]["trace" ]["span_id" ]
104- assert span ["trace_id" ] == client_transaction ["contexts" ]["trace" ]["trace_id" ]
103+ assert span ["parent_span_id" ] == client_root_span ["contexts" ]["trace" ]["span_id" ]
104+ assert span ["trace_id" ] == client_root_span ["contexts" ]["trace" ]["trace_id" ]
105105
106- (span ,) = worker_transaction ["spans" ]
106+ (span ,) = worker_root_span ["spans" ]
107107 assert span ["op" ] == "task"
108108 assert span ["origin" ] == "manual"
109109 assert span ["description" ] == "example task step"
110- assert span ["parent_span_id" ] == worker_transaction ["contexts" ]["trace" ]["span_id" ]
111- assert span ["trace_id" ] == worker_transaction ["contexts" ]["trace" ]["trace_id" ]
110+ assert span ["parent_span_id" ] == worker_root_span ["contexts" ]["trace" ]["span_id" ]
111+ assert span ["trace_id" ] == worker_root_span ["contexts" ]["trace" ]["trace_id" ]
112112
113113 assert (
114- client_transaction ["contexts" ]["trace" ]["trace_id" ]
115- == worker_transaction ["contexts" ]["trace" ]["trace_id" ]
114+ client_root_span ["contexts" ]["trace" ]["trace_id" ]
115+ == worker_root_span ["contexts" ]["trace" ]["trace_id" ]
116116 )
117117
118118
@@ -132,7 +132,7 @@ def test_errors_in_ray_tasks():
132132 def example_task ():
133133 1 / 0
134134
135- with sentry_sdk .start_transaction (op = "task " , name = "ray test transaction " ):
135+ with sentry_sdk .start_span (op = "test " , name = "ray client root span " ):
136136 with pytest .raises (ZeroDivisionError ):
137137 future = example_task .remote ()
138138 ray .get (future )
@@ -167,22 +167,24 @@ def __init__(self):
167167 self .n = 0
168168
169169 def increment (self ):
170- with sentry_sdk .start_span (op = "task" , name = "example actor execution" ):
170+ with sentry_sdk .start_span (
171+ op = "test" , name = "custom span in actor execution" , only_if_parent = True
172+ ):
171173 self .n += 1
172174
173175 return sentry_sdk .get_client ().transport .envelopes
174176
175- with sentry_sdk .start_transaction (op = "task " , name = "ray test transaction " ):
177+ with sentry_sdk .start_span (op = "test " , name = "ray client root span " ):
176178 counter = Counter .remote ()
177179 worker_envelopes = ray .get (counter .increment .remote ())
178180
179181 client_envelope = sentry_sdk .get_client ().transport .envelopes [0 ]
180- client_transaction = client_envelope .get_transaction_event ()
182+ client_root_span = client_envelope .get_transaction_event ()
181183
182184 # Spans for submitting the actor task are not created (actors are not supported yet)
183- assert client_transaction ["spans" ] == []
185+ assert client_root_span ["spans" ] == []
184186
185- # Transaction are not yet created when executing ray actors (actors are not supported yet)
187+ # Root spans are not yet automatically created when executing ray actors (actors are not supported yet)
186188 assert worker_envelopes == []
187189
188190
@@ -204,12 +206,14 @@ def __init__(self):
204206 self .n = 0
205207
206208 def increment (self ):
207- with sentry_sdk .start_span (op = "task" , name = "example actor execution" ):
209+ with sentry_sdk .start_span (
210+ op = "test" , name = "custom span in actor execution" , only_if_parent = True
211+ ):
208212 1 / 0
209213
210214 return sentry_sdk .get_client ().transport .envelopes
211215
212- with sentry_sdk .start_transaction (op = "task " , name = "ray test transaction " ):
216+ with sentry_sdk .start_span (op = "test " , name = "ray client root span " ):
213217 with pytest .raises (ZeroDivisionError ):
214218 counter = Counter .remote ()
215219 future = counter .increment .remote ()
0 commit comments