-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrii Soldatenko
committed
Jan 16, 2023
1 parent
d20d71e
commit b074f9a
Showing
6 changed files
with
50 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
import logging | ||
|
||
from sentry.dynamic_sampling.prioritise_projects import fetch_projects_with_total_volumes | ||
from sentry.tasks.base import instrumented_task | ||
|
||
CHUNK_SIZE = 1000 | ||
MAX_SECONDS = 60 | ||
|
||
logger = logging.getLogger("sentry.tasks.dynamic_sampling") | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@instrumented_task( | ||
name="sentry.dynamic_sampling.tasks.foo", | ||
queue="releasemonitor", | ||
name="sentry.dynamic_sampling.tasks.prioritise_projects", | ||
queue="dynamicsampling", | ||
default_retry_delay=5, | ||
max_retries=5, | ||
) # type: ignore | ||
def foo(**kwargs) -> None: | ||
def prioritise_projects(**kwargs) -> None: | ||
for org_id, project_ids in fetch_projects_with_total_volumes().items(): | ||
process_projects_with_sessions.delay(org_id, project_ids) | ||
process_projects_sample_rates.delay(org_id, project_ids) | ||
|
||
|
||
@instrumented_task( | ||
name="sentry.dynamic_sampling.process_projects_sample_rates", | ||
queue="dynamicsampling", | ||
default_retry_delay=5, | ||
max_retries=5, | ||
) # type: ignore | ||
def process_projects_sample_rates(org_id, project_ids) -> None: | ||
""" | ||
Takes a single org id and a list of project ids | ||
""" | ||
... | ||
|
||
# Get adjusted sample rate via adjustment model | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from sentry.dynamic_sampling.tasks import fetch_projects_with_total_volumes | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_simple(default_project): | ||
test_data = [ | ||
{ | ||
"org_id": [default_project.organization.id], | ||
"project_id": [default_project.id], | ||
}, | ||
] | ||
assert 1 == 1 | ||
_ = test_data | ||
fetch_projects_with_total_volumes() |