@@ -250,13 +250,19 @@ def boost_low_volume_projects_of_org(
250
250
Task to adjust the sample rates of the projects of a single organization specified by an
251
251
organization ID. Transaction counts and rates have to be provided.
252
252
"""
253
- logger .info (
254
- "boost_low_volume_projects_of_org" ,
255
- extra = {"traceparent" : sentry_sdk .get_traceparent (), "baggage" : sentry_sdk .get_baggage ()},
256
- )
253
+
257
254
rebalanced_projects = calculate_sample_rates_of_projects (
258
255
org_id , projects_with_tx_count_and_rates
259
256
)
257
+
258
+ logger .info (
259
+ "boost_low_volume_projects_of_org" ,
260
+ extra = {
261
+ "traceparent" : sentry_sdk .get_traceparent (),
262
+ "baggage" : sentry_sdk .get_baggage (),
263
+ "org_id" : org_id ,
264
+ },
265
+ )
260
266
if rebalanced_projects is not None :
261
267
store_rebalanced_projects (org_id , rebalanced_projects )
262
268
@@ -435,10 +441,27 @@ def calculate_sample_rates_of_projects(
435
441
436
442
# If we have the sliding window org sample rate, we use that or fall back to the blended sample rate in case of
437
443
# issues.
444
+
445
+ default_sample_rate = quotas .backend .get_blended_sample_rate (organization_id = org_id )
446
+ should_log_project_config = features .has ("organizations:log-project-config" , organization )
447
+
438
448
sample_rate , success = get_org_sample_rate (
439
449
org_id = org_id ,
440
- default_sample_rate = quotas . backend . get_blended_sample_rate ( organization_id = org_id ) ,
450
+ default_sample_rate = default_sample_rate ,
441
451
)
452
+
453
+ if should_log_project_config :
454
+ logger .info (
455
+ "log-project-config: calculate_sample_rates_of_projects for org %s" ,
456
+ org_id ,
457
+ extra = {
458
+ "org" : org_id ,
459
+ "target_sample_rate" : sample_rate ,
460
+ "success" : success ,
461
+ "default_sample_rate" : default_sample_rate ,
462
+ },
463
+ )
464
+
442
465
if success :
443
466
sample_function (
444
467
function = log_sample_rate_source ,
@@ -470,6 +493,14 @@ def calculate_sample_rates_of_projects(
470
493
projects_with_counts = {
471
494
project_id : count_per_root for project_id , count_per_root , _ , _ in projects_with_tx_count
472
495
}
496
+
497
+ if should_log_project_config :
498
+ logger .info (
499
+ "log-project-config: calculate_sample_rates_of_projects for org %s" ,
500
+ org_id ,
501
+ extra = {"projects_with_counts" : projects_with_counts , "sample_rate" : sample_rate },
502
+ )
503
+
473
504
# The rebalancing will not work (or would make sense) when we have only projects with zero-counts.
474
505
if not any (projects_with_counts .values ()):
475
506
return None
@@ -502,6 +533,26 @@ def calculate_sample_rates_of_projects(
502
533
rebalanced_projects : list [RebalancedItem ] | None = guarded_run (
503
534
model , ProjectsRebalancingInput (classes = projects , sample_rate = sample_rate )
504
535
)
536
+ if should_log_project_config :
537
+ logger .info (
538
+ "log-project-config: rebalanced_projects for org %s" ,
539
+ org_id ,
540
+ extra = {
541
+ "rebalanced_projects" : (
542
+ [
543
+ {
544
+ "id" : project .id ,
545
+ "count" : project .count ,
546
+ "new_sample_rate" : project .new_sample_rate ,
547
+ }
548
+ for project in rebalanced_projects
549
+ ]
550
+ if rebalanced_projects
551
+ else None
552
+ ),
553
+ "sample_rate" : sample_rate ,
554
+ },
555
+ )
505
556
506
557
return rebalanced_projects
507
558
0 commit comments