Skip to content

Commit 4c55a71

Browse files
committed
Merge branch 'master' into ryan953/ref-replay-hydration-diff-loading
2 parents e21280b + 2cf4319 commit 4c55a71

File tree

48 files changed

+1022
-336
lines changed

Some content is hidden

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

48 files changed

+1022
-336
lines changed

src/sentry/api/endpoints/organization_release_meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def get(self, request: Request, organization, version) -> Response:
104104
"version": release.version,
105105
"versionInfo": expose_version_info(release.version_info),
106106
"projects": projects,
107-
"newGroups": release.new_groups,
107+
"newGroups": sum(project["newGroups"] for project in projects),
108108
"deployCount": release.total_deploys,
109109
"commitCount": release.commit_count,
110110
"released": release.date_released or release.date_added,

src/sentry/api/endpoints/project_seer_preferences.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class ProjectSeerPreferencesEndpoint(ProjectEndpoint):
5454
}
5555

5656
def post(self, request: Request, project: Project) -> Response:
57-
if not features.has("organizations:autofix-seer-preferences", project.organization):
57+
if not features.has(
58+
"organizations:autofix-seer-preferences", project.organization, actor=request.user
59+
):
5860
return Response("Feature flag not enabled", status=403)
5961

6062
data = orjson.loads(request.body)
@@ -86,7 +88,9 @@ def post(self, request: Request, project: Project) -> Response:
8688
return Response(status=204)
8789

8890
def get(self, request: Request, project: Project) -> Response:
89-
if not features.has("organizations:autofix-seer-preferences", project.organization):
91+
if not features.has(
92+
"organizations:autofix-seer-preferences", project.organization, actor=request.user
93+
):
9094
return Response("Feature flag not enabled", status=403)
9195

9296
path = "/v1/project-preference"

src/sentry/conf/server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3025,7 +3025,6 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
30253025
"buffered-segments": "default",
30263026
"buffered-segments-dlq": "default",
30273027
"taskworker": "default",
3028-
"task-worker": "default",
30293028
"snuba-ourlogs": "default",
30303029
}
30313030

src/sentry/conf/types/kafka_definition.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class Topic(Enum):
6565
BUFFERED_SEGMENTS = "buffered-segments"
6666
BUFFERED_SEGMENTS_DLQ = "buffered-segments-dlq"
6767
TASKWORKER = "taskworker"
68-
TASK_WORKER = "task-worker"
6968

7069

7170
class ConsumerDefinition(TypedDict, total=False):

src/sentry/integrations/discord/actions/metric_alert.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ def send_incident_alert_notification(
3434
notification_context: NotificationContext,
3535
metric_issue_context: MetricIssueContext,
3636
open_period_context: OpenPeriodContext,
37-
alert_rule_serialized_response: AlertRuleSerializerResponse,
38-
incident_serialized_response: DetailedIncidentSerializerResponse,
37+
alert_rule_serialized_response: AlertRuleSerializerResponse | None,
38+
incident_serialized_response: DetailedIncidentSerializerResponse | None,
3939
notification_uuid: str | None = None,
4040
) -> bool:
4141
chart_url = None
42-
if features.has("organizations:metric-alert-chartcuterie", organization):
42+
if (
43+
features.has("organizations:metric-alert-chartcuterie", organization)
44+
and alert_rule_serialized_response
45+
and incident_serialized_response
46+
):
4347
try:
4448
chart_url = build_metric_alert_chart(
4549
organization=organization,

src/sentry/integrations/msteams/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def send_incident_alert_notification(
110110
notification_context: NotificationContext,
111111
metric_issue_context: MetricIssueContext,
112112
open_period_context: OpenPeriodContext,
113-
alert_rule_serialized_response: AlertRuleSerializerResponse,
114-
incident_serialized_response: DetailedIncidentSerializerResponse,
113+
alert_rule_serialized_response: AlertRuleSerializerResponse | None,
114+
incident_serialized_response: DetailedIncidentSerializerResponse | None,
115115
notification_uuid: str | None = None,
116116
) -> bool:
117117
from .card_builder.incident_attachment import build_incident_attachment

src/sentry/integrations/slack/utils/notifications.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,16 @@ def _build_notification_payload(
187187
alert_context: AlertContext,
188188
metric_issue_context: MetricIssueContext,
189189
open_period_context: OpenPeriodContext,
190-
alert_rule_serialized_response: AlertRuleSerializerResponse,
191-
incident_serialized_response: DetailedIncidentSerializerResponse,
190+
alert_rule_serialized_response: AlertRuleSerializerResponse | None,
191+
incident_serialized_response: DetailedIncidentSerializerResponse | None,
192192
notification_uuid: str | None,
193193
) -> tuple[str, str]:
194194
chart_url = None
195-
if features.has("organizations:metric-alert-chartcuterie", organization):
195+
if (
196+
features.has("organizations:metric-alert-chartcuterie", organization)
197+
and alert_rule_serialized_response
198+
and incident_serialized_response
199+
):
196200
try:
197201
chart_url = build_metric_alert_chart(
198202
organization=organization,
@@ -395,8 +399,8 @@ def send_incident_alert_notification(
395399
notification_context: NotificationContext,
396400
metric_issue_context: MetricIssueContext,
397401
open_period_context: OpenPeriodContext,
398-
alert_rule_serialized_response: AlertRuleSerializerResponse,
399-
incident_serialized_response: DetailedIncidentSerializerResponse,
402+
alert_rule_serialized_response: AlertRuleSerializerResponse | None,
403+
incident_serialized_response: DetailedIncidentSerializerResponse | None,
400404
notification_uuid: str | None = None,
401405
) -> bool:
402406
# Make sure organization integration is still active:

src/sentry/tasks/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from celery import Task, current_task
1111
from django.conf import settings
1212
from django.db.models import Model
13+
from kombu import Producer
1314

1415
from sentry import options
1516
from sentry.celery import app
@@ -80,6 +81,9 @@ def override(*args: P.args, **kwargs: P.kwargs) -> R:
8081

8182
random.seed(datetime.now().timestamp())
8283
if rollout > random.random():
84+
producer = kwargs.get("producer")
85+
if isinstance(producer, Producer):
86+
del kwargs["producer"]
8387
return taskworker_attr(*args, **kwargs)
8488

8589
return celery_task_attr(*args, **kwargs)

src/sentry/taskworker/registry.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ def wrapped(func: Callable[P, R]) -> Task[P, R]:
132132
def _handle_produce_future(self, future: ProducerFuture, tags: dict[str, str]) -> None:
133133
if future.cancelled():
134134
metrics.incr("taskworker.registry.send_task.cancelled", tags=tags)
135-
elif future.exception(
136-
1
137-
): # this does not block since this callback only gets run when the future is finished and exception is set
135+
elif future.exception(1):
136+
# this does not block since this callback only gets run when the future is finished and exception is set
138137
metrics.incr("taskworker.registry.send_task.failed", tags=tags)
139138
else:
140139
metrics.incr("taskworker.registry.send_task.success", tags=tags)

src/sentry/taskworker/worker.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def child_worker(
8282
for module in settings.TASKWORKER_IMPORTS:
8383
__import__(module)
8484

85-
current_task_id: str | None = None
85+
current_activation: TaskActivation | None = None
8686
processed_task_count = 0
8787

8888
def handle_alarm(signum: int, frame: Any) -> None:
@@ -92,13 +92,21 @@ def handle_alarm(signum: int, frame: Any) -> None:
9292
If we hit an alarm in a child, we need to push a result
9393
and terminate the child.
9494
"""
95-
nonlocal current_task_id, processed_tasks
95+
nonlocal current_activation, processed_tasks
9696

97-
if current_task_id:
97+
if current_activation:
9898
processed_tasks.put(
99-
ProcessingResult(task_id=current_task_id, status=TASK_ACTIVATION_STATUS_FAILURE)
99+
ProcessingResult(
100+
task_id=current_activation.id, status=TASK_ACTIVATION_STATUS_FAILURE
101+
)
102+
)
103+
metrics.incr(
104+
"taskworker.worker.processing_deadline_exceeded",
105+
tags={
106+
"namespace": current_activation.namespace,
107+
"taskname": current_activation.taskname,
108+
},
100109
)
101-
metrics.incr("taskworker.worker.processing_deadline_exceeded")
102110
sys.exit(1)
103111

104112
signal.signal(signal.SIGALRM, handle_alarm)
@@ -137,15 +145,15 @@ def handle_alarm(signum: int, frame: Any) -> None:
137145
key = get_at_most_once_key(activation.namespace, activation.taskname, activation.id)
138146
if cache.add(key, "1", timeout=AT_MOST_ONCE_TIMEOUT): # The key didn't exist
139147
metrics.incr(
140-
"taskworker.task.at_most_once.executed", tags={"task": activation.taskname}
148+
"taskworker.task.at_most_once.executed", tags={"taskname": activation.taskname}
141149
)
142150
else:
143151
metrics.incr(
144-
"taskworker.worker.at_most_once.skipped", tags={"task": activation.taskname}
152+
"taskworker.worker.at_most_once.skipped", tags={"taskname": activation.taskname}
145153
)
146154
continue
147155

148-
current_task_id = activation.id
156+
current_activation = activation
149157

150158
# Set an alarm for the processing_deadline_duration
151159
signal.alarm(activation.processing_deadline_duration)
@@ -159,7 +167,7 @@ def handle_alarm(signum: int, frame: Any) -> None:
159167
signal.alarm(0)
160168
except Exception as err:
161169
if task_func.should_retry(activation.retry_state, err):
162-
logger.info("taskworker.task.retry", extra={"task": activation.taskname})
170+
logger.info("taskworker.task.retry", extra={"taskname": activation.taskname})
163171
next_state = TASK_ACTIVATION_STATUS_RETRY
164172

165173
if next_state != TASK_ACTIVATION_STATUS_RETRY:
@@ -199,12 +207,12 @@ def handle_alarm(signum: int, frame: Any) -> None:
199207
metrics.distribution(
200208
"taskworker.worker.execution_duration",
201209
execution_duration,
202-
tags={"namespace": activation.namespace},
210+
tags={"namespace": activation.namespace, "taskname": activation.taskname},
203211
)
204212
metrics.distribution(
205213
"taskworker.worker.execution_latency",
206214
execution_latency,
207-
tags={"namespace": activation.namespace},
215+
tags={"namespace": activation.namespace, "taskname": activation.taskname},
208216
)
209217

210218

0 commit comments

Comments
 (0)