@@ -470,64 +470,77 @@ def envelope_with_spans(
470
470
headers = {"metrics_extracted" : metrics_extracted , "item_count" : 2 },
471
471
content_type = "application/vnd.sentry.items.span.v2+json" ,
472
472
payload = PayloadRef (
473
- json = {"items" : [
474
- {
475
- "trace_id" : "89143b0763095bd9c9955e8175d1fb23" ,
476
- "span_id" : "a342abb1214ca182" ,
477
- "name" : "my 1st V2 span" ,
478
- "kind" : "unspecified" ,
479
- "start_timestamp" : start .timestamp (),
480
- "end_timestamp" : end .timestamp (),
481
- "attributes" : {
482
- "sentry.category" : {
483
- "type" : "string" ,
484
- "value" : "db" ,
485
- },
486
- "sentry.exclusive_time_nano" : {
487
- "type" : "integer" ,
488
- "value" : int ((end - start ).total_seconds () * 1e9 ),
473
+ json = {
474
+ "items" : [
475
+ {
476
+ "trace_id" : "89143b0763095bd9c9955e8175d1fb23" ,
477
+ "span_id" : "a342abb1214ca182" ,
478
+ "name" : "my 1st V2 span" ,
479
+ "start_timestamp" : start .timestamp (),
480
+ "end_timestamp" : end .timestamp (),
481
+ "attributes" : {
482
+ "sentry.category" : {
483
+ "type" : "string" ,
484
+ "value" : "db" ,
485
+ },
486
+ "sentry.exclusive_time_nano" : {
487
+ "type" : "integer" ,
488
+ "value" : int ((end - start ).total_seconds () * 1e9 ),
489
+ },
489
490
},
491
+ "links" : [
492
+ {
493
+ "trace_id" : "89143b0763095bd9c9955e8175d1fb24" ,
494
+ "span_id" : "e342abb1214ca183" ,
495
+ "sampled" : False ,
496
+ "attributes" : {
497
+ "link_double_key" : {
498
+ "type" : "double" ,
499
+ "value" : 1.23 ,
500
+ },
501
+ },
502
+ },
503
+ ],
490
504
},
491
- "links" : [
492
- {
493
- "trace_id" : "89143b0763095bd9c9955e8175d1fb24" ,
494
- "span_id" : "e342abb1214ca183" ,
495
- "sampled" : False ,
496
- "attributes" : {
497
- "link_double_key" : {
498
- "type" : "double" ,
499
- "value" : 1.23 ,
505
+ {
506
+ "trace_id" : "ff62a8b040f340bda5d830223def1d81" ,
507
+ "span_id" : "b0429c44b67a3eb2" ,
508
+ "name" : "resource.script" ,
509
+ "status" : "ok" ,
510
+ "start_timestamp" : start .timestamp (),
511
+ "end_timestamp" : end .timestamp () + 1 ,
512
+ "links" : [
513
+ {
514
+ "trace_id" : "99143b0763095bd9c9955e8175d1fb25" ,
515
+ "span_id" : "e342abb1214ca183" ,
516
+ "sampled" : True ,
517
+ "attributes" : {
518
+ "link_bool_key" : {
519
+ "type" : "boolean" ,
520
+ "value" : True ,
521
+ },
500
522
},
501
523
},
502
- },
503
- ],
504
- },
505
- {
506
- "trace_id" : "ff62a8b040f340bda5d830223def1d81" ,
507
- "span_id" : "b0429c44b67a3eb2" ,
508
- "name" : "resource.script" ,
509
- "status" : "ok" ,
510
- "start_timestamp" : start .timestamp (),
511
- "end_timestamp" : end .timestamp () + 1 ,
512
- "links" : [
513
- {
514
- "trace_id" : "99143b0763095bd9c9955e8175d1fb25" ,
515
- "span_id" : "e342abb1214ca183" ,
516
- "sampled" : True ,
517
- "attributes" : {
518
- "link_bool_key" : {"type" : "boolean" , "value" : True },
524
+ ],
525
+ "attributes" : {
526
+ "browser.name" : {"type" : "string" , "value" : "Chrome" },
527
+ "sentry.description" : {
528
+ "type" : "string" ,
529
+ "value" : "https://example.com/p/blah.js" ,
530
+ },
531
+ "sentry.exclusive_time_nano" : {
532
+ "type" : "integer" ,
533
+ "value" : 161 * 1e6 ,
534
+ },
535
+ # Span with the same `span_id` and `segment_id`, to make sure it is classified as `is_segment`.
536
+ "sentry.segment.id" : {
537
+ "type" : "string" ,
538
+ "value" : "b0429c44b67a3eb2" ,
519
539
},
520
540
},
521
- ],
522
- "attributes" : {
523
- "browser.name" : {"type" : "string" , "value" : "Chrome" },
524
- "sentry.description" : {"type" : "string" , "value" : "https://example.com/p/blah.js" },
525
- "sentry.exclusive_time_nano" : {"type" : "integer" , "value" : 345 * 1e6 },
526
- # Span with the same `span_id` and `segment_id`, to make sure it is classified as `is_segment`.
527
- "sentry.segment_id" : {"type" : "string" , "value" : "b0429c44b67a3eb2" }
528
541
},
529
- }
530
- ] }
542
+ ]
543
+ }
531
544
),
532
545
)
533
546
)
@@ -775,7 +788,6 @@ def test_span_ingestion(
775
788
"exclusive_time_ms" : 500.0 ,
776
789
"is_segment" : True ,
777
790
"is_remote" : False ,
778
- "kind" : "unspecified" ,
779
791
"links" : [
780
792
{
781
793
"trace_id" : "89143b0763095bd9c9955e8175d1fb24" ,
@@ -853,7 +865,7 @@ def test_span_ingestion(
853
865
},
854
866
"description" : "https://example.com/p/blah.js" ,
855
867
"duration_ms" : 1500 ,
856
- "exclusive_time_ms" : 345 .0 ,
868
+ "exclusive_time_ms" : 161 .0 ,
857
869
"is_segment" : True ,
858
870
"is_remote" : False ,
859
871
"links" : [
@@ -1046,7 +1058,7 @@ def test_span_ingestion(
1046
1058
"tags" : {"decision" : "keep" , "target_project_id" : "42" },
1047
1059
"timestamp" : expected_timestamp + 1 ,
1048
1060
"type" : "c" ,
1049
- "value" : 3 .0 ,
1061
+ "value" : 4 .0 ,
1050
1062
},
1051
1063
{
1052
1064
"name" : "c:spans/usage@none" ,
@@ -1067,7 +1079,7 @@ def test_span_ingestion(
1067
1079
"tags" : {},
1068
1080
"timestamp" : expected_timestamp + 1 ,
1069
1081
"type" : "c" ,
1070
- "value" : 3 .0 ,
1082
+ "value" : 4 .0 ,
1071
1083
"received_at" : time_after (now_timestamp ),
1072
1084
},
1073
1085
{
@@ -1085,7 +1097,7 @@ def test_span_ingestion(
1085
1097
},
1086
1098
"timestamp" : expected_timestamp + 1 ,
1087
1099
"type" : "d" ,
1088
- "value" : [1500.0 ],
1100
+ "value" : [1500.0 , 1500.0 ],
1089
1101
"received_at" : time_after (now_timestamp ),
1090
1102
},
1091
1103
{
@@ -1169,7 +1181,7 @@ def test_span_ingestion(
1169
1181
},
1170
1182
"timestamp" : expected_timestamp + 1 ,
1171
1183
"type" : "d" ,
1172
- "value" : [1500.0 ],
1184
+ "value" : [1500.0 , 1500.0 ],
1173
1185
},
1174
1186
{
1175
1187
"name" : "d:spans/duration_light@millisecond" ,
@@ -1198,7 +1210,7 @@ def test_span_ingestion(
1198
1210
"project_id" : 42 ,
1199
1211
"name" : "d:spans/exclusive_time@millisecond" ,
1200
1212
"type" : "d" ,
1201
- "value" : [345.0 ],
1213
+ "value" : [161.0 , 345.0 ],
1202
1214
"timestamp" : expected_timestamp + 1 ,
1203
1215
"tags" : {
1204
1216
"file_extension" : "js" ,
@@ -1271,7 +1283,7 @@ def test_span_ingestion(
1271
1283
"project_id" : 42 ,
1272
1284
"name" : "d:spans/exclusive_time_light@millisecond" ,
1273
1285
"type" : "d" ,
1274
- "value" : [345.0 ],
1286
+ "value" : [161.0 , 345.0 ],
1275
1287
"timestamp" : expected_timestamp + 1 ,
1276
1288
"tags" : {
1277
1289
"file_extension" : "js" ,
@@ -1318,7 +1330,13 @@ def test_span_ingestion(
1318
1330
"received_at" : time_after (now_timestamp ),
1319
1331
},
1320
1332
]
1321
- assert [m for m in metrics if ":spans/" in m ["name" ]] == expected_span_metrics
1333
+
1334
+ span_metrics = [m for m in metrics if ":spans/" in m ["name" ]]
1335
+
1336
+ assert len (span_metrics ) == len (expected_span_metrics )
1337
+ for actual , expected in zip (span_metrics , expected_span_metrics ):
1338
+ assert actual == expected
1339
+ # assert [m for m in metrics if ":spans/" in m["name"]] == expected_span_metrics
1322
1340
1323
1341
# Regardless of whether transactions are extracted, score.total is only converted to a transaction metric once:
1324
1342
score_total_metrics = [
@@ -1703,7 +1721,7 @@ def test_rate_limit_indexed_consistent(
1703
1721
project_config ["config" ]["quotas" ] = [
1704
1722
{
1705
1723
"categories" : ["span_indexed" ],
1706
- "limit" : 4 ,
1724
+ "limit" : 6 ,
1707
1725
"window" : int (datetime .now (UTC ).timestamp ()),
1708
1726
"id" : uuid .uuid4 (),
1709
1727
"reasonCode" : "indexed_exceeded" ,
@@ -1726,13 +1744,13 @@ def summarize_outcomes():
1726
1744
1727
1745
# First batch passes
1728
1746
relay .send_envelope (project_id , envelope )
1729
- spans = spans_consumer .get_spans (n = 4 , timeout = 10 )
1730
- assert len (spans ) == 4
1731
- assert summarize_outcomes () == {(16 , 0 ): 4 } # SpanIndexed, Accepted
1747
+ spans = spans_consumer .get_spans (n = 6 , timeout = 10 )
1748
+ assert len (spans ) == 6
1749
+ assert summarize_outcomes () == {(16 , 0 ): 6 } # SpanIndexed, Accepted
1732
1750
1733
1751
# Second batch is limited
1734
1752
relay .send_envelope (project_id , envelope )
1735
- assert summarize_outcomes () == {(16 , 2 ): 4 } # SpanIndexed, RateLimited
1753
+ assert summarize_outcomes () == {(16 , 2 ): 6 } # SpanIndexed, RateLimited
1736
1754
1737
1755
spans_consumer .assert_empty ()
1738
1756
outcomes_consumer .assert_empty ()
@@ -1877,7 +1895,7 @@ def summarize_outcomes():
1877
1895
1878
1896
relay .send_envelope (project_id , envelope )
1879
1897
1880
- assert summarize_outcomes () == {(12 , 2 ): 4 , (16 , 2 ): 4 }
1898
+ assert summarize_outcomes () == {(12 , 2 ): 6 , (16 , 2 ): 6 }
1881
1899
1882
1900
# We emit transaction metrics from spans for legacy reasons. These are not rate limited.
1883
1901
# (could be a bug)
@@ -2212,13 +2230,13 @@ def summarize_outcomes(outcomes):
2212
2230
return counter
2213
2231
2214
2232
if sample_rate == 1.0 :
2215
- spans = spans_consumer .get_spans (timeout = 10 , n = 4 )
2216
- assert len (spans ) == 4
2217
- outcomes = outcomes_consumer .get_outcomes (timeout = 10 , n = 4 )
2218
- assert summarize_outcomes (outcomes ) == {(16 , 0 ): 4 } # SpanIndexed, Accepted
2233
+ spans = spans_consumer .get_spans (timeout = 10 , n = 6 )
2234
+ assert len (spans ) == 6
2235
+ outcomes = outcomes_consumer .get_outcomes (timeout = 10 , n = 6 )
2236
+ assert summarize_outcomes (outcomes ) == {(16 , 0 ): 6 } # SpanIndexed, Accepted
2219
2237
else :
2220
2238
outcomes = outcomes_consumer .get_outcomes (timeout = 10 , n = 1 )
2221
- assert summarize_outcomes (outcomes ) == {(16 , 1 ): 4 } # Span, Filtered
2239
+ assert summarize_outcomes (outcomes ) == {(16 , 1 ): 6 } # Span, Filtered
2222
2240
assert {o ["reason" ] for o in outcomes } == {"Sampled:3000" }
2223
2241
2224
2242
spans_consumer .assert_empty ()
@@ -2477,6 +2495,7 @@ def test_scrubs_ip_addresses(
2477
2495
2478
2496
spans_consumer .assert_empty ()
2479
2497
2498
+
2480
2499
def test_spans_v2_multiple_containers_not_allowed (
2481
2500
mini_sentry ,
2482
2501
relay_with_processing ,
0 commit comments