From 015522e043338bba172a7eea0340225dd78a9dc1 Mon Sep 17 00:00:00 2001 From: Andrii Soldatenko Date: Tue, 7 Feb 2023 13:37:21 +0100 Subject: [PATCH] fix tests --- src/sentry/dynamic_sampling/prioritise_projects.py | 8 +++++--- src/sentry/dynamic_sampling/tasks.py | 2 +- src/sentry/snuba/dataset.py | 1 + .../sentry/dynamic_sampling/test_prioritise_projects.py | 9 +++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/sentry/dynamic_sampling/prioritise_projects.py b/src/sentry/dynamic_sampling/prioritise_projects.py index 47abe40f229339..00ba6ffe9f60fb 100644 --- a/src/sentry/dynamic_sampling/prioritise_projects.py +++ b/src/sentry/dynamic_sampling/prioritise_projects.py @@ -23,7 +23,7 @@ def fetch_projects_with_total_volumes() -> Mapping[int, Sequence[int]]: while (time.time() - start_time) < MAX_SECONDS: query = ( Query( - match=Entity(EntityKey.OrgMetricsCounters.value), + match=Entity(EntityKey.GenericMetricsCounters.value), select=[ Column("org_id"), Column("project_id"), @@ -47,10 +47,12 @@ def fetch_projects_with_total_volumes() -> Mapping[int, Sequence[int]]: .set_limit(CHUNK_SIZE + 1) .set_offset(offset) ) - request = Request(dataset=Dataset.Metrics.value, app_id="dynamic_sampling", query=query) + request = Request( + dataset=Dataset.PerformanceMetrics.value, app_id="dynamic_sampling", query=query + ) data = raw_snql_query( request, - referrer="dynamic_sampling.fetch_projects_with_total_volumes", + referrer="dynamic_sampling.fetch_projects_with_count_per_root_total_volumes", )["data"] count = len(data) more_results = count > CHUNK_SIZE diff --git a/src/sentry/dynamic_sampling/tasks.py b/src/sentry/dynamic_sampling/tasks.py index 6d69e7a638f28a..99a4cbc486465d 100644 --- a/src/sentry/dynamic_sampling/tasks.py +++ b/src/sentry/dynamic_sampling/tasks.py @@ -34,4 +34,4 @@ def process_projects_sample_rates(org_id, project_ids) -> None: # Get adjusted sample rate via adjustment model # - # prioritize_projects.delay(org_id, project_ids) + # prioritise_projects.delay(org_id, project_ids) diff --git a/src/sentry/snuba/dataset.py b/src/sentry/snuba/dataset.py index 47014bd3d99d3b..45a4f460d7bae7 100644 --- a/src/sentry/snuba/dataset.py +++ b/src/sentry/snuba/dataset.py @@ -28,4 +28,5 @@ class EntityKey(Enum): MetricsDistributions = "metrics_distributions" GenericMetricsDistributions = "generic_metrics_distributions" GenericMetricsSets = "generic_metrics_sets" + GenericMetricsCounters = "generic_metrics_counters" IssuePlatform = "search_issues" diff --git a/tests/sentry/dynamic_sampling/test_prioritise_projects.py b/tests/sentry/dynamic_sampling/test_prioritise_projects.py index e2b3008e4ad5e7..99e5ac65ba7b89 100644 --- a/tests/sentry/dynamic_sampling/test_prioritise_projects.py +++ b/tests/sentry/dynamic_sampling/test_prioritise_projects.py @@ -1,6 +1,11 @@ +import pytest + from sentry.dynamic_sampling.prioritise_projects import fetch_projects_with_total_volumes +from sentry.testutils.factories import Factories +@pytest.mark.django_db def test_prioritize_projects(): - results = fetch_projects_with_total_volumes() - 1 == 1 + organization = Factories.create_organization(name="test-org") + Factories.create_project(organization=organization) + fetch_projects_with_total_volumes()