Skip to content

feat(dynamic-sampling): Add project slug to response of AM2 check #53514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/sentry/tasks/check_am2_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import defaultdict
from datetime import datetime, timedelta
from enum import Enum
from typing import Any, Dict, List, Mapping, Optional, Set, Tuple
from typing import Any, Dict, Mapping, Optional, Set, Tuple

import pytz
import sentry_sdk
Expand Down Expand Up @@ -410,19 +410,14 @@ def get_all_alerts_of_organization(cls, organization_id):

@classmethod
def get_organization_metrics_compatibility(cls, organization, project_objects):
data: Dict[str, List[Any]] = {
"incompatible_projects": [],
"compatible_projects": [],
}

params = {
"organization_id": organization.id,
"project_objects": project_objects,
"start": datetime.now(tz=pytz.UTC) - timedelta(days=QUERY_TIME_RANGE_IN_DAYS),
"end": datetime.now(tz=pytz.UTC),
}

project_ids = [project.id for project in project_objects]
projects = {project.id: project for project in project_objects}

count_has_txn = "count_has_transaction_name()"
count_null = "count_null_transactions()"
Expand All @@ -439,14 +434,19 @@ def get_organization_metrics_compatibility(cls, organization, project_objects):
use_aggregate_conditions=True,
)

data["compatible_projects"] = sorted(
row["project.id"] for row in compatible_results["data"]
)
data["incompatible_projects"] = sorted(
list(set(project_ids) - set(data["compatible_projects"]))
)
compatible_project_ids = {row["project.id"] for row in compatible_results["data"]}
incompatible_project_ids = set(projects.keys()) - compatible_project_ids

return data
return {
"compatible_projects": [
{"id": project_id, "slug": projects[project_id].slug}
for project_id in compatible_project_ids
],
"incompatible_projects": [
{"id": project_id, "slug": projects[project_id].slug}
for project_id in incompatible_project_ids
],
}

@classmethod
def run_compatibility_check(cls, org_id):
Expand Down