@@ -323,6 +323,48 @@ def test_set_meaurement_public_api(sentry_init, capture_events):
323
323
assert event ["measurements" ]["metric.bar" ] == {"value" : 456 , "unit" : "second" }
324
324
325
325
326
+ def test_set_measurement_deprecated (sentry_init ):
327
+ sentry_init (traces_sample_rate = 1.0 )
328
+
329
+ with start_transaction (name = "measuring stuff" ) as trx :
330
+ with pytest .warns (DeprecationWarning ):
331
+ set_measurement ("metric.foo" , 123 )
332
+
333
+ with pytest .warns (DeprecationWarning ):
334
+ trx .set_measurement ("metric.bar" , 456 )
335
+
336
+ with start_span (op = "measuring span" ) as span :
337
+ with pytest .warns (DeprecationWarning ):
338
+ span .set_measurement ("metric.baz" , 420.69 , unit = "custom" )
339
+
340
+
341
+ def test_set_meaurement_compared_to_set_data (sentry_init , capture_events ):
342
+ """
343
+ This is just a test to see the difference
344
+ between measurements and data in the resulting event payload.
345
+ """
346
+ sentry_init (traces_sample_rate = 1.0 )
347
+
348
+ events = capture_events ()
349
+
350
+ with start_transaction (name = "measuring stuff" ) as transaction :
351
+ transaction .set_measurement ("metric.foo" , 123 )
352
+ transaction .set_data ("metric.bar" , 456 )
353
+
354
+ with start_span (op = "measuring span" ) as span :
355
+ span .set_measurement ("metric.baz" , 420.69 , unit = "custom" )
356
+ span .set_data ("metric.qux" , 789 )
357
+
358
+ (event ,) = events
359
+ assert event ["measurements" ]["metric.foo" ] == {"value" : 123 , "unit" : "" }
360
+ assert event ["contexts" ]["trace" ]["data" ]["metric.bar" ] == 456
361
+ assert event ["spans" ][0 ]["measurements" ]["metric.baz" ] == {
362
+ "value" : 420.69 ,
363
+ "unit" : "custom" ,
364
+ }
365
+ assert event ["spans" ][0 ]["data" ]["metric.qux" ] == 789
366
+
367
+
326
368
@pytest .mark .parametrize (
327
369
"trace_propagation_targets,url,expected_propagation_decision" ,
328
370
[
0 commit comments