44from datetime import datetime , timedelta
55from typing import Mapping , Sequence
66
7- from snuba_sdk import (
8- Column ,
9- Condition ,
10- Direction ,
11- Entity ,
12- Function ,
13- Granularity ,
14- Op ,
15- OrderBy ,
16- Query ,
17- Request ,
18- )
7+ from snuba_sdk import Column , Condition , Direction , Entity , Granularity , Op , OrderBy , Query , Request
198
20- from sentry .release_health .release_monitor .base import BaseReleaseMonitorBackend , Totals
21- from sentry .sentry_metrics import indexer
22- from sentry .sentry_metrics .configuration import UseCaseKey
23- from sentry .sentry_metrics .indexer .strings import SESSION_METRIC_NAMES
24- from sentry .sentry_metrics .utils import resolve_tag_key
9+ from sentry .sentry_metrics .indexer .strings import TRANSACTION_METRICS_NAMES
2510from sentry .snuba .dataset import Dataset , EntityKey
26- from sentry .snuba .metrics .naming_layer .mri import SessionMRI
27- from sentry .utils import metrics
11+ from sentry .snuba .metrics .naming_layer .mri import TransactionMRI
2812from sentry .utils .snuba import raw_snql_query
2913
3014logger = logging .getLogger (__name__ )
3317
3418
3519def fetch_projects_with_total_volumes () -> Mapping [int , Sequence [int ]]:
36- # TODO: (andrii) include only "disconnected" projects or independent in tracing context
3720 aggregated_projects = defaultdict (list )
3821 start_time = time .time ()
3922 offset = 0
@@ -52,7 +35,7 @@ def fetch_projects_with_total_volumes() -> Mapping[int, Sequence[int]]:
5235 Condition (
5336 Column ("metric_id" ),
5437 Op .EQ ,
55- SESSION_METRIC_NAMES [ SessionMRI . SESSION .value ],
38+ TRANSACTION_METRICS_NAMES [ TransactionMRI . COUNT_PER_ROOT_PROJECT .value ],
5639 ),
5740 ],
5841 granularity = Granularity (3600 ),
@@ -66,9 +49,8 @@ def fetch_projects_with_total_volumes() -> Mapping[int, Sequence[int]]:
6649 )
6750 request = Request (dataset = Dataset .Metrics .value , app_id = "dynamic_sampling" , query = query )
6851 data = raw_snql_query (
69- # TODO: replace to new referrer
7052 request ,
71- referrer = "dynamic_sampling.fetch_projects_with_recent_sessions " ,
53+ referrer = "dynamic_sampling.fetch_projects_with_total_volumes " ,
7254 )["data" ]
7355 count = len (data )
7456 more_results = count > CHUNK_SIZE
@@ -90,3 +72,7 @@ def fetch_projects_with_total_volumes() -> Mapping[int, Sequence[int]]:
9072 )
9173
9274 return aggregated_projects
75+
76+
77+ def process_projects_with_total_volumes (project_ids ):
78+ ...
0 commit comments