@@ -325,3 +325,38 @@ def test_partition_by_measure_with_span_feature_flag_disabled(self) -> None:
325325 assert SamplingMeasure .TRANSACTIONS in result
326326 assert SamplingMeasure .SPANS not in result
327327 assert result [SamplingMeasure .TRANSACTIONS ] == [org .id ]
328+
329+ def test_partition_by_measure_returns_sorted_output_multiple_orgs (self ) -> None :
330+ orgs = [self .create_organization (f"test-org{ i } " ) for i in range (10 )]
331+ org_ids = [org .id for org in reversed (orgs )]
332+
333+ with self .options (
334+ {
335+ "dynamic-sampling.check_span_feature_flag" : True ,
336+ "dynamic-sampling.measure.spans" : [orgs [2 ].id , orgs [7 ].id , orgs [5 ].id ],
337+ }
338+ ):
339+ result = partition_by_measure (org_ids )
340+
341+ assert result [SamplingMeasure .SPANS ] == sorted ([orgs [2 ].id , orgs [7 ].id , orgs [5 ].id ])
342+ expected_transaction_orgs = sorted (
343+ [org .id for org in orgs if org .id not in [orgs [2 ].id , orgs [7 ].id , orgs [5 ].id ]]
344+ )
345+ assert result [SamplingMeasure .TRANSACTIONS ] == expected_transaction_orgs
346+
347+ def test_partition_by_measure_returns_sorted_when_feature_disabled (self ) -> None :
348+ org1 = self .create_organization ("test-org1" )
349+ org2 = self .create_organization ("test-org2" )
350+ org3 = self .create_organization ("test-org3" )
351+
352+ org_ids = [org3 .id , org1 .id , org2 .id ]
353+
354+ with self .options (
355+ {
356+ "dynamic-sampling.check_span_feature_flag" : False ,
357+ }
358+ ):
359+ result = partition_by_measure (org_ids )
360+
361+ assert result [SamplingMeasure .TRANSACTIONS ] == sorted (org_ids )
362+ assert SamplingMeasure .SPANS not in result
0 commit comments