Skip to content

Commit 9c29440

Browse files
authored
Merge branch 'master' into jb/node/24
2 parents 837eccf + 44c963e commit 9c29440

File tree

46 files changed

+838
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+838
-437
lines changed

src/sentry/api/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
SourceMapDebugEndpoint,
218218
TeamGroupsOldEndpoint,
219219
)
220+
from sentry.issues.endpoints.browser_reporting_collector import BrowserReportingCollectorEndpoint
220221
from sentry.issues.endpoints.organization_group_search_view_starred_order import (
221222
OrganizationGroupSearchViewStarredOrderEndpoint,
222223
)
@@ -3491,6 +3492,12 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
34913492
SecretScanningGitHubEndpoint.as_view(),
34923493
name="sentry-api-0-secret-scanning-github",
34933494
),
3495+
# Temporary public endpoint for proxying browser reports to GCP, to gather real-world data
3496+
re_path(
3497+
r"^reporting-api-experiment/$",
3498+
BrowserReportingCollectorEndpoint.as_view(),
3499+
name="sentry-api-0-reporting-api-experiment",
3500+
),
34943501
# Catch all
34953502
re_path(
34963503
r"^$",

src/sentry/apidocs/parameters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ class PreventParams:
10591059
location="query",
10601060
required=False,
10611061
type=str,
1062-
description="""The branch to search for results by. If not specified, the default branch is returned.
1062+
description="""The branch to search for results by. If not specified, the default is `main`.
10631063
""",
10641064
)
10651065
TEST_RESULTS_FILTER_BY = OpenApiParameter(
@@ -1081,7 +1081,7 @@ class PreventParams:
10811081
location="query",
10821082
required=False,
10831083
type=str,
1084-
description="""The property to sort results by. If not specified, all results are returned. Use `-`
1084+
description="""The property to sort results by. If not specified, the default is `COMMITS_WHERE_FAIL` in descending order. Use `-`
10851085
for descending order.
10861086
10871087
Available fields are:

src/sentry/codecov/endpoints/TestResults/test_results.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def has_pagination(self, response):
5050
def get(self, request: Request, owner: str, repository: str, **kwargs) -> Response:
5151
"""Retrieves the list of test results for a given repository and owner. Also accepts a number of query parameters to filter the results."""
5252

53-
sort_by = request.query_params.get("sortBy", OrderingParameter.COMMITS_WHERE_FAIL.value)
53+
sort_by = request.query_params.get(
54+
"sortBy", f"-{OrderingParameter.COMMITS_WHERE_FAIL.value}"
55+
)
5456

5557
if sort_by and sort_by.startswith("-"):
5658
sort_by = sort_by[1:]

src/sentry/features/temporary.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ def register_temporary_features(manager: FeatureManager):
422422
manager.add("organizations:transaction-name-normalize", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, default=True, api_expose=False)
423423
# Enables automatically triggering autofix on issue summary
424424
manager.add("organizations:trigger-autofix-on-issue-summary", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
425+
# Enables unlimited auto-triggered autofix runs
426+
manager.add("organizations:unlimited-auto-triggered-autofix-runs", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
425427
# Enables automatic hostname detection in uptime
426428
manager.add("organizations:uptime-automatic-hostname-detection", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
427429
# Enables automatic subscription creation in uptime

src/sentry/integrations/github/webhook.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ def get_file_language(filename: str) -> str | None:
6464
if extension != filename:
6565
language = EXTENSION_LANGUAGE_MAP.get(extension)
6666

67-
if language is None:
68-
logger.info("github.unaccounted_file_lang", extra={"extension": extension})
69-
7067
return language
7168

7269

src/sentry/integrations/source_code_management/commit_context.py

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -223,42 +223,34 @@ def queue_pr_comment_task_if_needed(
223223
except NotImplementedError:
224224
return
225225

226+
if not OrganizationOption.objects.get_value(
227+
organization=project.organization,
228+
key=pr_comment_workflow.organization_option_key,
229+
default=True,
230+
):
231+
return
232+
233+
repo_query = Repository.objects.filter(id=commit.repository_id).order_by("-date_added")
234+
group = Group.objects.get_from_cache(id=group_id)
235+
if not (
236+
group.level is not logging.INFO and repo_query.exists()
237+
): # Don't comment on info level issues
238+
return
239+
226240
with CommitContextIntegrationInteractionEvent(
227241
interaction_type=SCMIntegrationInteractionType.QUEUE_COMMENT_TASK,
228242
provider_key=self.integration_name,
229243
organization=project.organization,
230244
project=project,
231245
commit=commit,
232246
).capture() as lifecycle:
233-
if not OrganizationOption.objects.get_value(
234-
organization=project.organization,
235-
key=pr_comment_workflow.organization_option_key,
236-
default=True,
237-
):
238-
# TODO: remove logger in favor of the log recorded in lifecycle.record_halt
239-
logger.info(
240-
_pr_comment_log(integration_name=self.integration_name, suffix="disabled"),
241-
extra={"organization_id": project.organization_id},
242-
)
243-
lifecycle.record_halt(CommitContextHaltReason.PR_BOT_DISABLED)
244-
return
245-
246-
repo_query = Repository.objects.filter(id=commit.repository_id).order_by("-date_added")
247-
group = Group.objects.get_from_cache(id=group_id)
248-
if not (
249-
group.level is not logging.INFO and repo_query.exists()
250-
): # Don't comment on info level issues
251-
logger.info(
252-
_pr_comment_log(
253-
integration_name=self.integration_name, suffix="incorrect_repo_config"
254-
),
255-
extra={"organization_id": project.organization_id},
256-
)
257-
lifecycle.record_halt(CommitContextHaltReason.INCORRECT_REPO_CONFIG)
258-
return
259-
260247
repo: Repository = repo_query.get()
261-
lifecycle.add_extra("repository_id", repo.id)
248+
lifecycle.add_extras(
249+
{
250+
"repository_id": repo.id,
251+
"group_id": group_id,
252+
}
253+
)
262254

263255
logger.info(
264256
_pr_comment_log(
@@ -282,37 +274,18 @@ def queue_pr_comment_task_if_needed(
282274
return
283275

284276
if merge_commit_sha is None:
285-
logger.info(
286-
_pr_comment_log(
287-
integration_name=self.integration_name,
288-
suffix="queue_comment_workflow.commit_not_in_default_branch",
289-
),
290-
extra={
291-
"organization_id": commit.organization_id,
292-
"repository_id": repo.id,
293-
"commit_sha": commit.key,
294-
},
295-
)
277+
lifecycle.add_extra("commit_sha", commit.key)
296278
lifecycle.record_halt(CommitContextHaltReason.COMMIT_NOT_IN_DEFAULT_BRANCH)
297279
return
298280

281+
lifecycle.add_extra("merge_commit_sha", merge_commit_sha)
282+
299283
pr_query = PullRequest.objects.filter(
300284
organization_id=commit.organization_id,
301285
repository_id=commit.repository_id,
302286
merge_commit_sha=merge_commit_sha,
303287
)
304288
if not pr_query.exists():
305-
logger.info(
306-
_pr_comment_log(
307-
integration_name=self.integration_name,
308-
suffix="queue_comment_workflow.missing_pr",
309-
),
310-
extra={
311-
"organization_id": commit.organization_id,
312-
"repository_id": repo.id,
313-
"commit_sha": commit.key,
314-
},
315-
)
316289
lifecycle.record_halt(CommitContextHaltReason.MISSING_PR)
317290
return
318291

src/sentry/integrations/source_code_management/metrics.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ def get_extras(self) -> Mapping[str, Any]:
105105
class CommitContextHaltReason(StrEnum):
106106
"""Common reasons why a commit context integration may halt without success/failure."""
107107

108-
PR_BOT_DISABLED = "pr_bot_disabled"
109-
INCORRECT_REPO_CONFIG = "incorrect_repo_config"
110108
COMMIT_NOT_IN_DEFAULT_BRANCH = "commit_not_in_default_branch"
111109
MISSING_PR = "missing_pr"
112110
ALREADY_QUEUED = "already_queued"

src/sentry/integrations/source_code_management/tasks.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ def pr_comment_workflow(pr_id: int, project_id: int):
143143
top_5_issue_ids = [issue["group_id"] for issue in top_5_issues]
144144

145145
comment_body = pr_comment_workflow.get_comment_body(issue_ids=top_5_issue_ids)
146-
logger.info(
147-
_pr_comment_log(integration_name=integration_name, suffix="comment_body"),
148-
extra={"body": comment_body},
149-
)
150146

151147
top_24_issue_ids = issue_ids[:24] # 24 is the P99 for issues-per-PR
152148

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import logging
2+
3+
from django.http import HttpResponse
4+
from django.views.decorators.csrf import csrf_exempt
5+
from rest_framework.parsers import JSONParser
6+
from rest_framework.request import Request
7+
8+
from sentry import options
9+
from sentry.api.api_owners import ApiOwner
10+
from sentry.api.api_publish_status import ApiPublishStatus
11+
from sentry.api.base import Endpoint, all_silo_endpoint, allow_cors_options
12+
from sentry.utils import metrics
13+
14+
logger = logging.getLogger(__name__)
15+
16+
17+
@all_silo_endpoint
18+
class BrowserReportingCollectorEndpoint(Endpoint):
19+
"""
20+
An experimental endpoint which is a proxy for browser Reporting API reports. For now just
21+
records metrics and forwards data to GCP, so we can collect real-world data on what gets sent,
22+
how much gets sent, etc.
23+
"""
24+
25+
permission_classes = ()
26+
# TODO: Do we need to specify this parser? Content type will be `application/reports+json`, so
27+
# it might just work automatically.
28+
parser_classes = [JSONParser]
29+
publish_status = {
30+
"POST": ApiPublishStatus.PRIVATE,
31+
}
32+
owner = ApiOwner.ISSUES
33+
34+
# TODO: It's unclear if either of these decorators is necessary
35+
@csrf_exempt
36+
@allow_cors_options
37+
def post(self, request: Request, *args, **kwargs) -> HttpResponse:
38+
if not options.get("issues.browser_reporting.collector_endpoint_enabled"):
39+
return HttpResponse(status=404)
40+
41+
logger.info("browser_report_received", extra={"request_body": request.data})
42+
43+
metrics.incr(
44+
"browser_reporting.raw_report_received", tags={"type": request.data.get("type")}
45+
)
46+
47+
return HttpResponse(status=200)

src/sentry/options/defaults.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@
599599

600600
# Issue Summary on Alerts (timeout in seconds)
601601
register("alerts.issue_summary_timeout", default=5, flags=FLAG_AUTOMATOR_MODIFIABLE)
602+
# Issue Summary Auto-trigger rate (max number of autofix runs auto-triggered per project per hour)
603+
register("seer.max_num_autofix_autotriggered_per_hour", default=20, flags=FLAG_AUTOMATOR_MODIFIABLE)
602604

603605
# Codecov Integration
604606
register("codecov.client-secret", flags=FLAG_CREDENTIAL | FLAG_PRIORITIZE_DISK)
@@ -3449,3 +3451,12 @@
34493451
default=[],
34503452
flags=FLAG_ALLOW_EMPTY | FLAG_AUTOMATOR_MODIFIABLE,
34513453
)
3454+
3455+
# Enable the collection of Reporting API reports via the `/api/0/reporting-api-experiment/`
3456+
# endpoint. When this is false, the endpoint will just 404.
3457+
register(
3458+
"issues.browser_reporting.collector_endpoint_enabled",
3459+
type=Bool,
3460+
default=False,
3461+
flags=FLAG_AUTOMATOR_MODIFIABLE,
3462+
)

src/sentry/rules/processing/delayed_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def fire_rules(
549549
"group_id": group.id,
550550
},
551551
)
552-
break
552+
continue
553553

554554
updated = (
555555
GroupRuleStatus.objects.filter(id=status.id)
@@ -567,7 +567,7 @@ def fire_rules(
567567
"group_id": group.id,
568568
},
569569
)
570-
break
570+
continue
571571

572572
notification_uuid = str(uuid.uuid4())
573573
groupevent = group_to_groupevent[group]

0 commit comments

Comments
 (0)