@@ -77,42 +77,42 @@ def example_task():
77
77
78
78
return sentry_sdk .get_client ().transport .envelopes
79
79
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 " ):
81
81
worker_envelopes = ray .get (example_task .remote ())
82
82
83
83
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" }
87
87
88
88
worker_envelope = worker_envelopes [0 ]
89
- worker_transaction = worker_envelope .get_transaction_event ()
89
+ worker_root_span = worker_envelope .get_transaction_event ()
90
90
assert (
91
- worker_transaction ["transaction" ]
91
+ worker_root_span ["transaction" ]
92
92
== "tests.integrations.ray.test_ray.test_tracing_in_ray_tasks.<locals>.example_task"
93
93
)
94
- assert worker_transaction ["transaction_info" ] == {"source" : "task" }
94
+ assert worker_root_span ["transaction_info" ] == {"source" : "task" }
95
95
96
- (span ,) = client_transaction ["spans" ]
96
+ (span ,) = client_root_span ["spans" ]
97
97
assert span ["op" ] == "queue.submit.ray"
98
98
assert span ["origin" ] == "auto.queue.ray"
99
99
assert (
100
100
span ["description" ]
101
101
== "tests.integrations.ray.test_ray.test_tracing_in_ray_tasks.<locals>.example_task"
102
102
)
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" ]
105
105
106
- (span ,) = worker_transaction ["spans" ]
106
+ (span ,) = worker_root_span ["spans" ]
107
107
assert span ["op" ] == "task"
108
108
assert span ["origin" ] == "manual"
109
109
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" ]
112
112
113
113
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" ]
116
116
)
117
117
118
118
@@ -132,7 +132,7 @@ def test_errors_in_ray_tasks():
132
132
def example_task ():
133
133
1 / 0
134
134
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 " ):
136
136
with pytest .raises (ZeroDivisionError ):
137
137
future = example_task .remote ()
138
138
ray .get (future )
@@ -167,22 +167,24 @@ def __init__(self):
167
167
self .n = 0
168
168
169
169
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
+ ):
171
173
self .n += 1
172
174
173
175
return sentry_sdk .get_client ().transport .envelopes
174
176
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 " ):
176
178
counter = Counter .remote ()
177
179
worker_envelopes = ray .get (counter .increment .remote ())
178
180
179
181
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 ()
181
183
182
184
# 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" ] == []
184
186
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)
186
188
assert worker_envelopes == []
187
189
188
190
@@ -204,12 +206,14 @@ def __init__(self):
204
206
self .n = 0
205
207
206
208
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
+ ):
208
212
1 / 0
209
213
210
214
return sentry_sdk .get_client ().transport .envelopes
211
215
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 " ):
213
217
with pytest .raises (ZeroDivisionError ):
214
218
counter = Counter .remote ()
215
219
future = counter .increment .remote ()
0 commit comments