Skip to content

Commit 49cc0cd

Browse files
kconsandrewshie-sentry
authored andcommitted
feat(rules): Wrap IntegrationEventAction future callbacks in a span (#91850)
Add a wrapper span to our future callbacks to improve tracing of actions.
1 parent 1118228 commit 49cc0cd

File tree

1 file changed

+22
-0
lines changed
  • src/sentry/rules/actions/integrations

1 file changed

+22
-0
lines changed

src/sentry/rules/actions/integrations/base.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from __future__ import annotations
22

33
import abc
4+
from collections.abc import Callable, Sequence
5+
from typing import Any, override
6+
7+
import sentry_sdk
48

59
from sentry import analytics
610
from sentry.eventstore.models import GroupEvent
@@ -12,6 +16,8 @@
1216
from sentry.models.organization import OrganizationStatus
1317
from sentry.models.rule import Rule
1418
from sentry.rules.actions import EventAction
19+
from sentry.rules.base import CallbackFuture
20+
from sentry.types.rules import RuleFuture
1521

1622
INTEGRATION_KEY = "integration"
1723

@@ -34,6 +40,22 @@ def provider(self) -> str:
3440
def integration_key(self) -> str:
3541
pass
3642

43+
@override
44+
def future(
45+
self,
46+
callback: Callable[[GroupEvent, Sequence[RuleFuture]], None],
47+
key: str | None = None,
48+
**kwargs: Any,
49+
) -> CallbackFuture:
50+
def wrapped_callback(event: GroupEvent, futures: Sequence[RuleFuture]) -> None:
51+
with sentry_sdk.start_span(
52+
op="IntegrationEventAction.future",
53+
name=type(self).__name__,
54+
):
55+
callback(event, futures)
56+
57+
return super().future(wrapped_callback, key, **kwargs)
58+
3759
def is_enabled(self) -> bool:
3860
enabled: bool = bool(self.get_integrations())
3961
return enabled

0 commit comments

Comments
 (0)