Skip to content

Commit 6d4edd3

Browse files
committed
Merge branch 'master' into tkdodo/ref/knip-zero
# Conflicts: # tests/js/fixtures/dataConditions.ts # tests/js/fixtures/detectors.ts
2 parents 0bfe441 + 39c9c48 commit 6d4edd3

File tree

755 files changed

+11135
-47058
lines changed

Some content is hidden

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

755 files changed

+11135
-47058
lines changed

fixtures/events/performance_problems/n-plus-one-db/n-plus-one-db-mongoose.json

Lines changed: 755 additions & 0 deletions
Large diffs are not rendered by default.

migrations_lockfile.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ ahead of you.
55
To resolve this, rebase against latest master and regenerate your migration. This file
66
will then be regenerated, and you should be able to merge without conflicts.
77

8-
explore: 0004_add_explore_last_visited_table
8+
explore: 0001_squashed_0004_add_explore_last_visited_table
99

10-
feedback: 0004_index_together
10+
feedback: 0001_squashed_0004_index_together
1111

12-
flags: 0004_add_flag_audit_log_provider_column
12+
flags: 0001_squashed_0004_add_flag_audit_log_provider_column
1313

14-
hybridcloud: 0021_django_arrayfield_scope_list
14+
hybridcloud: 0001_squashed_0021_django_arrayfield_scope_list
1515

16-
insights: 0001_add_starred_transactions_model
16+
insights: 0001_squashed_0001_add_starred_transactions_model
1717

18-
monitors: 0005_record_date_in_progress_state
18+
monitors: 0001_squashed_0005_record_date_in_progress_state
1919

20-
nodestore: 0002_nodestore_no_dictfield
20+
nodestore: 0001_squashed_0002_nodestore_no_dictfield
2121

22-
replays: 0005_drop_replay_index
22+
replays: 0001_squashed_0005_drop_replay_index
2323

24-
sentry: 0904_onboarding_task_project_id_idx
24+
sentry: 0908_increase_email_field_length
2525

26-
social_auth: 0002_default_auto_field
26+
social_auth: 0001_squashed_0002_default_auto_field
2727

28-
tempest: 0002_make_message_type_nullable
28+
tempest: 0001_squashed_0002_make_message_type_nullable
2929

30-
uptime: 0042_extra_uptime_indexes
30+
uptime: 0001_squashed_0042_extra_uptime_indexes
3131

32-
workflow_engine: 0065_add_status_to_detector_and_workflow
32+
workflow_engine: 0001_squashed_0065_add_status_to_detector_and_workflow

src/sentry/api/bases/organization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def is_not_2fa_compliant(
6464
if request.user.is_authenticated and request.user.is_sentry_app:
6565
return False
6666

67+
if request.user.is_anonymous:
68+
return False
69+
6770
if is_active_superuser(request):
6871
return False
6972

src/sentry/api/endpoints/trace_explorer_ai_query.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ class TraceExplorerAIQuery(OrganizationEndpoint):
6363
@staticmethod
6464
def post(request: Request, organization: Organization) -> Response:
6565
"""
66-
Checks if we are able to run Autofix on the given group.
66+
Request to translate a natural language query into a sentry EQS query.
6767
"""
6868
if not request.user.is_authenticated:
6969
return Response(status=status.HTTP_400_BAD_REQUEST)
7070

7171
project_ids = [int(x) for x in request.data.get("project_ids", [])]
7272
natural_language_query = request.data.get("natural_language_query")
73+
limit = request.data.get("limit", 1)
74+
use_flyout = request.data.get("use_flyout", True)
7375

7476
if len(project_ids) == 0 or not natural_language_query:
7577
return Response(
@@ -102,15 +104,50 @@ def post(request: Request, organization: Organization) -> Response:
102104
)
103105
data = send_translate_request(organization.id, project_ids, natural_language_query)
104106

107+
# XXX: This is a fallback to support the old response format until we fully support using multiple queries on the frontend
108+
if "responses" in data and use_flyout:
109+
if not data["responses"]:
110+
logger.info("No results found for query")
111+
return Response(
112+
{"detail": "No results found for query"},
113+
status=status.HTTP_404_NOT_FOUND,
114+
)
115+
data = data["responses"][0]
116+
if "responses" not in data:
117+
return Response(
118+
{
119+
"status": "ok",
120+
"query": data["query"], # the sentry EQS query as a string
121+
"stats_period": data["stats_period"],
122+
"group_by": list(data.get("group_by", [])),
123+
"visualization": list(
124+
data.get("visualization")
125+
), # [{chart_type: 1, y_axes: ["count_message"]}, ...]
126+
"sort": data["sort"],
127+
}
128+
)
129+
130+
data = data["responses"][:limit]
131+
132+
if len(data) == 0:
133+
logger.info("No results found for query")
134+
return Response(
135+
{"detail": "No results found for query"},
136+
status=status.HTTP_404_NOT_FOUND,
137+
)
138+
105139
return Response(
106140
{
107141
"status": "ok",
108-
"query": data["query"], # the sentry EQS query as a string
109-
"stats_period": data["stats_period"],
110-
"group_by": list(data.get("group_by", [])),
111-
"visualization": list(
112-
data.get("visualization")
113-
), # [{chart_type: 1, y_axes: ["count_message"]}, ...]
114-
"sort": data["sort"],
142+
"queries": [
143+
{
144+
"query": query["query"],
145+
"stats_period": query["stats_period"],
146+
"group_by": list(query.get("group_by", [])),
147+
"visualization": list(query.get("visualization")),
148+
"sort": query["sort"],
149+
}
150+
for query in data
151+
],
115152
}
116153
)

src/sentry/api/permissions.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,26 @@ def determine_access(
167167
organization = org_context.organization
168168
extra = {"organization_id": organization.id, "user_id": user_id}
169169

170-
if self.is_not_2fa_compliant(request, organization):
171-
logger.info(
172-
"access.not-2fa-compliant.dry-run",
173-
extra=extra,
174-
)
175-
170+
is_token_access_allowed = False
176171
if request.auth and request.user and request.user.is_authenticated:
177172
request.access = access.from_request_org_and_scopes(
178173
request=request,
179174
rpc_user_org_context=org_context,
180175
scopes=request.auth.get_scopes(),
181176
)
182-
return
183-
184-
if request.auth:
177+
is_token_access_allowed = True
178+
elif request.auth:
185179
request.access = access.from_rpc_auth(
186180
auth=request.auth, rpc_user_org_context=org_context
187181
)
182+
is_token_access_allowed = True
183+
184+
if is_token_access_allowed:
185+
if self.is_not_2fa_compliant(request, organization):
186+
logger.info(
187+
"access.not-2fa-compliant.dry-run",
188+
extra=extra,
189+
)
188190
return
189191

190192
request.access = access.from_request_org_and_scopes(

src/sentry/apidocs/examples/integration_examples.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class IntegrationExamples:
288288
"featureGate": "integrations-commits",
289289
},
290290
{
291-
"description": "Create and link Sentry issue groups directly to a GitHub issue or pull\n request in any of your repositories, providing a quick way to jump from\n Sentry bug to tracked issue or PR!",
291+
"description": "Create and link Sentry issue groups directly to a GitHub issue or pull\n request in any of your repositories, providing a quick way to jump from\n Sentry bug to tracked issue or PR.",
292292
"featureGate": "integrations-issue-basic",
293293
},
294294
{
@@ -331,7 +331,7 @@ class IntegrationExamples:
331331
"featureGate": "integrations-commits",
332332
},
333333
{
334-
"description": "Create and link Sentry issue groups directly to a GitHub issue or pull\n request in any of your repositories, providing a quick way to jump from\n Sentry bug to tracked issue or PR!",
334+
"description": "Create and link Sentry issue groups directly to a GitHub issue or pull\n request in any of your repositories, providing a quick way to jump from\n Sentry bug to tracked issue or PR.",
335335
"featureGate": "integrations-issue-basic",
336336
},
337337
{
@@ -433,7 +433,7 @@ class IntegrationExamples:
433433
"description": "Connect your Sentry organization into one or more of your Jira cloud instances.\nGet started streamlining your bug squashing workflow by unifying your Sentry and\nJira instances together.",
434434
"features": [
435435
{
436-
"description": "Create and link Sentry issue groups directly to a Jira ticket in any of your\n projects, providing a quick way to jump from a Sentry bug to tracked ticket!",
436+
"description": "Create and link Sentry issue groups directly to a Jira ticket in any of your\n projects, providing a quick way to jump from a Sentry bug to tracked ticket.",
437437
"featureGate": "integrations-issue-basic",
438438
},
439439
{
@@ -478,7 +478,7 @@ class IntegrationExamples:
478478
"description": "Connect your Sentry organization into one or more of your Jira Server instances.\nGet started streamlining your bug squashing workflow by unifying your Sentry and\nJira instances together.",
479479
"features": [
480480
{
481-
"description": "Create and link Sentry issue groups directly to a Jira ticket in any of your\n projects, providing a quick way to jump from Sentry bug to tracked ticket!",
481+
"description": "Create and link Sentry issue groups directly to a Jira ticket in any of your\n projects, providing a quick way to jump from Sentry bug to tracked ticket.",
482482
"featureGate": "integrations-issue-basic",
483483
},
484484
{
@@ -707,7 +707,7 @@ class IntegrationExamples:
707707
"featureGate": "integrations-commits",
708708
},
709709
{
710-
"description": "Create and link Sentry issue groups directly to a Azure DevOps work item in any of\n your projects, providing a quick way to jump from Sentry bug to tracked\n work item!",
710+
"description": "Create and link Sentry issue groups directly to a Azure DevOps work item in any of\n your projects, providing a quick way to jump from Sentry bug to tracked\n work item.",
711711
"featureGate": "integrations-issue-basic",
712712
},
713713
{

src/sentry/apidocs/examples/project_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
"features": ["issue-basic"],
227227
"featureDescriptions": [
228228
{
229-
"description": "Create and link Sentry issue groups directly to an Asana ticket in any of your\n projects, providing a quick way to jump from a Sentry bug to tracked ticket!",
229+
"description": "Create and link Sentry issue groups directly to an Asana ticket in any of your\n projects, providing a quick way to jump from a Sentry bug to tracked ticket.",
230230
"featureGate": "issue-basic",
231231
},
232232
{

src/sentry/celery.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.db import models
1212
from django.utils.safestring import SafeString
1313

14-
from sentry.utils import metrics
14+
from sentry.utils import json, metrics
1515

1616
logger = logging.getLogger("celery.pickle")
1717

@@ -114,6 +114,19 @@ def apply_async(self, *args, **kwargs):
114114
)
115115
should_sample = random.random() <= settings.CELERY_PICKLE_ERROR_REPORT_SAMPLE_RATE
116116
if should_complain or should_sample:
117+
try:
118+
param_size = json.dumps({"args": args, "kwargs": kwargs})
119+
metrics.distribution(
120+
"celery.task.parameter_bytes",
121+
len(param_size.encode("utf8")),
122+
tags={"taskname": self.name},
123+
sample_rate=1.0,
124+
)
125+
except Exception as e:
126+
logger.warning(
127+
"task.payload.measure.failure", extra={"error": str(e), "task": self.name}
128+
)
129+
117130
try:
118131
good_use_of_pickle_or_bad_use_of_pickle(self, args, kwargs)
119132
except TypeError:

src/sentry/db/postgres/schema.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
)
55
from django.db.models import Field, Model
66
from django.db.models.base import ModelBase
7+
from django.db.models.constraints import BaseConstraint
78
from django_zero_downtime_migrations.backends.postgres.schema import (
89
DatabaseSchemaEditorMixin,
910
Unsafe,
@@ -67,6 +68,11 @@ def create_model(self, model: type[Model]) -> None:
6768
self.execute("CREATE EXTENSION IF NOT EXISTS btree_gist;")
6869
super().create_model(model)
6970

71+
def add_constraint(self, model: type[Model], constraint: BaseConstraint) -> None:
72+
if isinstance(constraint, ExclusionConstraint):
73+
self.execute("CREATE EXTENSION IF NOT EXISTS btree_gist;")
74+
super().add_constraint(model, constraint)
75+
7076

7177
class SafePostgresDatabaseSchemaEditor(DatabaseSchemaEditorMixin, PostgresDatabaseSchemaEditor):
7278
add_field = translate_unsafeoperation_exception(PostgresDatabaseSchemaEditor.add_field)

src/sentry/explore/migrations/0001_add_explore_saved_query_model.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)