Skip to content

Commit 79e0930

Browse files
committed
🔧 chore: add some more record_failures
1 parent 22ec07c commit 79e0930

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/sentry/integrations/source_code_management/commit_context.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,15 @@ def get_blame_for_files(
106106
).capture() as lifecycle:
107107
try:
108108
client = self.get_client()
109-
except Identity.DoesNotExist:
110-
sentry_sdk.capture_exception()
109+
except Identity.DoesNotExist as e:
110+
lifecycle.record_failure(e)
111+
sentry_sdk.capture_exception(e)
111112
return []
112113
try:
113114
response = client.get_blame_for_files(files, extra)
114-
except IdentityNotValid:
115-
sentry_sdk.capture_exception()
115+
except IdentityNotValid as e:
116+
lifecycle.record_failure(e)
117+
sentry_sdk.capture_exception(e)
116118
return []
117119
# Swallow rate limited errors so we don't log them as exceptions
118120
except ApiRateLimitedError as e:

src/sentry/integrations/source_code_management/metrics.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Mapping
2-
from enum import Enum, StrEnum
2+
from enum import StrEnum
33
from typing import Any
44

55
from attr import dataclass
@@ -15,7 +15,7 @@
1515
from sentry.organizations.services.organization import RpcOrganization
1616

1717

18-
class SCMIntegrationInteractionType(Enum):
18+
class SCMIntegrationInteractionType(StrEnum):
1919
"""
2020
SCM integration features
2121
"""
@@ -37,9 +37,6 @@ class SCMIntegrationInteractionType(Enum):
3737
# Tasks
3838
LINK_ALL_REPOS = "LINK_ALL_REPOS"
3939

40-
def __str__(self) -> str:
41-
return self.value.lower()
42-
4340

4441
@dataclass
4542
class SCMIntegrationInteractionEvent(IntegrationEventLifecycleMetric):
@@ -70,15 +67,6 @@ def get_extras(self) -> Mapping[str, Any]:
7067
}
7168

7269

73-
class LinkAllReposHaltReason(StrEnum):
74-
"""Common reasons why a link all repos task may halt without success/failure."""
75-
76-
MISSING_INTEGRATION = "missing_integration"
77-
MISSING_ORGANIZATION = "missing_organization"
78-
RATE_LIMITED = "rate_limited"
79-
REPOSITORY_NOT_CREATED = "repository_not_created"
80-
81-
8270
@dataclass
8371
class CommitContextIntegrationInteractionEvent(SCMIntegrationInteractionEvent):
8472
"""
@@ -109,3 +97,12 @@ class CommitContextHaltReason(StrEnum):
10997
COMMIT_NOT_IN_DEFAULT_BRANCH = "commit_not_in_default_branch"
11098
MISSING_PR = "missing_pr"
11199
ALREADY_QUEUED = "already_queued"
100+
101+
102+
class LinkAllReposHaltReason(StrEnum):
103+
"""Common reasons why a link all repos task may halt without success/failure."""
104+
105+
MISSING_INTEGRATION = "missing_integration"
106+
MISSING_ORGANIZATION = "missing_organization"
107+
RATE_LIMITED = "rate_limited"
108+
REPOSITORY_NOT_CREATED = "repository_not_created"

0 commit comments

Comments
 (0)