@@ -208,3 +208,45 @@ def test_children_span_nesting_mixed(capture_envelopes):
208
208
assert db_span ["parent_span_id" ] == payload ["contexts" ]["trace" ]["span_id" ]
209
209
assert http_span ["parent_span_id" ] == payload ["contexts" ]["trace" ]["span_id" ]
210
210
assert redis_span ["parent_span_id" ] == db_span ["span_id" ]
211
+
212
+
213
+ def test_span_attributes_in_data_started_with_otel (capture_envelopes ):
214
+ envelopes = capture_envelopes ()
215
+
216
+ with tracer .start_as_current_span ("request" ) as request_span :
217
+ request_span .set_attributes ({"foo" : "bar" , "baz" : 42 })
218
+ with tracer .start_as_current_span ("db" ) as db_span :
219
+ db_span .set_attributes ({"abc" : 99 , "def" : "moo" })
220
+
221
+ (envelope ,) = envelopes
222
+ (item ,) = envelope .items
223
+ payload = item .payload .json
224
+
225
+ assert payload ["contexts" ]["trace" ]["data" ] == {"foo" : "bar" , "baz" : 42 }
226
+ assert payload ["spans" ][0 ]["data" ] == {"abc" : 99 , "def" : "moo" }
227
+
228
+
229
+ def test_span_data_started_with_sentry (capture_envelopes ):
230
+ envelopes = capture_envelopes ()
231
+
232
+ with sentry_sdk .start_span (op = "http" , description = "request" ) as request_span :
233
+ request_span .set_data ("foo" , "bar" )
234
+ with sentry_sdk .start_span (op = "db" , description = "statement" ) as db_span :
235
+ db_span .set_data ("baz" , 42 )
236
+
237
+ (envelope ,) = envelopes
238
+ (item ,) = envelope .items
239
+ payload = item .payload .json
240
+
241
+ assert payload ["contexts" ]["trace" ]["data" ] == {
242
+ "foo" : "bar" ,
243
+ "sentry.origin" : "manual" ,
244
+ "sentry.description" : "request" ,
245
+ "sentry.op" : "http" ,
246
+ }
247
+ assert payload ["spans" ][0 ]["data" ] == {
248
+ "baz" : 42 ,
249
+ "sentry.origin" : "manual" ,
250
+ "sentry.description" : "statement" ,
251
+ "sentry.op" : "db" ,
252
+ }
0 commit comments