Skip to content

Commit 3777e4c

Browse files
authored
🔍 nit(aci): remove manual spans from noa (#97961)
1 parent 8e531f0 commit 3777e4c

File tree

1 file changed

+40
-55
lines changed
  • src/sentry/notifications/notification_action

1 file changed

+40
-55
lines changed

src/sentry/notifications/notification_action/types.py

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from dataclasses import asdict
66
from typing import Any, NotRequired, TypedDict
77

8-
import sentry_sdk
9-
108
from sentry import features
119
from sentry.constants import ObjectStatus
1210
from sentry.incidents.grouptype import MetricIssueEvidenceData
@@ -207,16 +205,13 @@ def get_rule_futures(
207205
This method will collect the futures from the activate_downstream_actions method.
208206
Based off of rule_processor.apply in rules/processing/processor.py
209207
"""
210-
with sentry_sdk.start_span(
211-
op="workflow_engine.handlers.action.notification.issue_alert.invoke_legacy_registry.activate_downstream_actions"
212-
):
213-
if not isinstance(event_data.event, GroupEvent):
214-
raise ValueError(
215-
f"WorkflowEventData.event expected GroupEvent, but received: {type(event_data.event).__name__}"
216-
)
208+
if not isinstance(event_data.event, GroupEvent):
209+
raise ValueError(
210+
f"WorkflowEventData.event expected GroupEvent, but received: {type(event_data.event).__name__}"
211+
)
217212

218-
grouped_futures = activate_downstream_actions(rule, event_data.event, notification_uuid)
219-
return grouped_futures.values()
213+
grouped_futures = activate_downstream_actions(rule, event_data.event, notification_uuid)
214+
return grouped_futures.values()
220215

221216
@staticmethod
222217
def execute_futures(
@@ -229,16 +224,13 @@ def execute_futures(
229224
This method will execute the futures.
230225
Based off of process_rules in post_process.py
231226
"""
232-
with sentry_sdk.start_span(
233-
op="workflow_engine.handlers.action.notification.issue_alert.execute_futures"
234-
):
235-
if not isinstance(event_data.event, GroupEvent):
236-
raise ValueError(
237-
"WorkflowEventData.event is not a GroupEvent when evaluating issue alerts"
238-
)
227+
if not isinstance(event_data.event, GroupEvent):
228+
raise ValueError(
229+
"WorkflowEventData.event is not a GroupEvent when evaluating issue alerts"
230+
)
239231

240-
for callback, future in futures:
241-
safe_execute(callback, event_data.event, future)
232+
for callback, future in futures:
233+
safe_execute(callback, event_data.event, future)
242234

243235
@staticmethod
244236
def send_test_notification(
@@ -256,11 +248,8 @@ def send_test_notification(
256248
"WorkflowEventData.event is not a GroupEvent when sending test notification"
257249
)
258250

259-
with sentry_sdk.start_span(
260-
op="workflow_engine.handlers.action.notification.issue_alert.execute_futures"
261-
):
262-
for callback, future in futures:
263-
callback(event_data.event, future)
251+
for callback, future in futures:
252+
callback(event_data.event, future)
264253

265254
@classmethod
266255
def invoke_legacy_registry(
@@ -276,38 +265,34 @@ def invoke_legacy_registry(
276265
2. activate_downstream_actions
277266
3. execute_futures (also in post_process process_rules)
278267
"""
268+
# Create a notification uuid
269+
notification_uuid = str(uuid.uuid4())
279270

280-
with sentry_sdk.start_span(
281-
op="workflow_engine.handlers.action.notification.issue_alert.invoke_legacy_registry"
282-
):
283-
# Create a notification uuid
284-
notification_uuid = str(uuid.uuid4())
285-
286-
# Create a rule
287-
rule = cls.create_rule_instance_from_action(action, detector, event_data)
288-
289-
logger.info(
290-
"notification_action.execute_via_issue_alert_handler",
291-
extra={
292-
"action_id": action.id,
293-
"detector_id": detector.id,
294-
"event_data": asdict(event_data),
295-
"rule_id": rule.id,
296-
"rule_project_id": rule.project.id,
297-
"rule_environment_id": rule.environment_id,
298-
"rule_label": rule.label,
299-
"rule_data": rule.data,
300-
},
301-
)
302-
# Get the futures
303-
futures = cls.get_rule_futures(event_data, rule, notification_uuid)
271+
# Create a rule
272+
rule = cls.create_rule_instance_from_action(action, detector, event_data)
304273

305-
# Execute the futures
306-
# If the rule id is -1, we are sending a test notification
307-
if rule.id == TEST_NOTIFICATION_ID:
308-
cls.send_test_notification(event_data, futures)
309-
else:
310-
cls.execute_futures(event_data, futures)
274+
logger.info(
275+
"notification_action.execute_via_issue_alert_handler",
276+
extra={
277+
"action_id": action.id,
278+
"detector_id": detector.id,
279+
"event_data": asdict(event_data),
280+
"rule_id": rule.id,
281+
"rule_project_id": rule.project.id,
282+
"rule_environment_id": rule.environment_id,
283+
"rule_label": rule.label,
284+
"rule_data": rule.data,
285+
},
286+
)
287+
# Get the futures
288+
futures = cls.get_rule_futures(event_data, rule, notification_uuid)
289+
290+
# Execute the futures
291+
# If the rule id is -1, we are sending a test notification
292+
if rule.id == TEST_NOTIFICATION_ID:
293+
cls.send_test_notification(event_data, futures)
294+
else:
295+
cls.execute_futures(event_data, futures)
311296

312297

313298
class TicketingIssueAlertHandler(BaseIssueAlertHandler):

0 commit comments

Comments
 (0)