Skip to content

Commit d2348db

Browse files
committed
🏗️ Setup new group type
1 parent 62fe205 commit d2348db

File tree

8 files changed

+24
-21
lines changed

8 files changed

+24
-21
lines changed

src/sentry/issues/grouptype.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,16 @@ class PerformanceNPlusOneAPICallsGroupType(GroupType):
339339
released = True
340340

341341

342+
@dataclass(frozen=True)
343+
class PerformanceNPlusOneAPICallsExperimentalGroupType(GroupType):
344+
type_id = 1910
345+
slug = "performance_n_plus_one_api_calls_experimental"
346+
description = "N+1 API Call (Experimental)"
347+
category = GroupCategory.PERFORMANCE.value
348+
default_priority = PriorityLevel.LOW
349+
released = False
350+
351+
342352
@dataclass(frozen=True)
343353
class PerformanceMNPlusOneDBQueriesGroupType(PerformanceGroupTypeDefaults, GroupType):
344354
type_id = 1011

src/sentry/notifications/utils/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from sentry.integrations.services.integration import integration_service
2222
from sentry.issues.grouptype import (
2323
PerformanceConsecutiveDBQueriesGroupType,
24+
PerformanceNPlusOneAPICallsExperimentalGroupType,
2425
PerformanceNPlusOneAPICallsGroupType,
2526
PerformanceRenderBlockingAssetSpanGroupType,
2627
)
@@ -336,7 +337,7 @@ def occurrence_perf_to_email_html(context: Any) -> str:
336337

337338

338339
def get_spans(
339-
entries: list[dict[str, list[dict[str, str | float]] | str]]
340+
entries: list[dict[str, list[dict[str, str | float]] | str]],
340341
) -> list[dict[str, str | float]] | None:
341342
"""Get the given event's spans"""
342343
if not len(entries):
@@ -496,7 +497,10 @@ def from_problem_and_spans(
496497
spans: list[dict[str, str | float]] | None,
497498
event: Event | None = None,
498499
) -> PerformanceProblemContext:
499-
if problem.type == PerformanceNPlusOneAPICallsGroupType:
500+
if problem.type in (
501+
PerformanceNPlusOneAPICallsGroupType,
502+
PerformanceNPlusOneAPICallsExperimentalGroupType,
503+
):
500504
return NPlusOneAPICallProblemContext(problem, spans, event)
501505
if problem.type == PerformanceConsecutiveDBQueriesGroupType:
502506
return ConsecutiveDBQueriesProblemContext(problem, spans, event)
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +0,0 @@
1-
from .consecutive_db_detector import ConsecutiveDBSpanDetector # NOQA
2-
from .consecutive_http_detector import ConsecutiveHTTPSpanDetector # NOQA
3-
from .http_overhead_detector import HTTPOverheadDetector # NOQA
4-
from .io_main_thread_detector import DBMainThreadDetector, FileIOMainThreadDetector # NOQA
5-
from .large_payload_detector import LargeHTTPPayloadDetector # NOQA
6-
from .mn_plus_one_db_span_detector import MNPlusOneDBSpanDetector # NOQA
7-
from .n_plus_one_api_calls_detector import NPlusOneAPICallsDetector # NOQA
8-
from .n_plus_one_db_span_detector import ( # NOQA
9-
NPlusOneDBSpanDetector,
10-
NPlusOneDBSpanDetectorExtended,
11-
)
12-
from .render_blocking_asset_span_detector import RenderBlockingAssetSpanDetector # NOQA
13-
from .slow_db_query_detector import SlowDBQueryDetector # NOQA
14-
from .uncompressed_asset_detector import UncompressedAssetSpanDetector # NOQA

src/sentry/utils/performance_issues/detectors/experiments/__init__.py

Whitespace-only changes.

src/sentry/utils/performance_issues/detectors/n_plus_one_api_calls_detector.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
from sentry.issues.issue_occurrence import IssueEvidence
1515
from sentry.models.organization import Organization
1616
from sentry.models.project import Project
17-
from sentry.utils.performance_issues.detectors.utils import get_total_span_duration
18-
19-
from ..base import (
17+
from sentry.utils.performance_issues.base import (
2018
DetectorType,
2119
PerformanceDetector,
2220
fingerprint_http_spans,
@@ -25,8 +23,9 @@
2523
get_url_from_span,
2624
parameterize_url,
2725
)
28-
from ..performance_problem import PerformanceProblem
29-
from ..types import PerformanceProblemsMap, Span
26+
from sentry.utils.performance_issues.detectors.utils import get_total_span_duration
27+
from sentry.utils.performance_issues.performance_problem import PerformanceProblem
28+
from sentry.utils.performance_issues.types import PerformanceProblemsMap, Span
3029

3130

3231
class NPlusOneAPICallsDetector(PerformanceDetector):

src/sentry/utils/performance_issues/performance_detection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
from .base import DetectorType, PerformanceDetector
2323
from .detectors.consecutive_db_detector import ConsecutiveDBSpanDetector
2424
from .detectors.consecutive_http_detector import ConsecutiveHTTPSpanDetector
25+
from .detectors.experiments.n_plus_one_api_calls_detector import (
26+
NPlusOneAPICallsExperimentalDetector,
27+
)
2528
from .detectors.http_overhead_detector import HTTPOverheadDetector
2629
from .detectors.io_main_thread_detector import DBMainThreadDetector, FileIOMainThreadDetector
2730
from .detectors.large_payload_detector import LargeHTTPPayloadDetector
@@ -322,6 +325,7 @@ def get_detection_settings(project_id: int | None = None) -> dict[DetectorType,
322325
NPlusOneDBSpanDetectorExtended,
323326
FileIOMainThreadDetector,
324327
NPlusOneAPICallsDetector,
328+
NPlusOneAPICallsExperimentalDetector,
325329
MNPlusOneDBSpanDetector,
326330
UncompressedAssetSpanDetector,
327331
LargeHTTPPayloadDetector,

tests/sentry/utils/performance_issues/__init__.py

Whitespace-only changes.

tests/sentry/utils/performance_issues/experiments/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)