Skip to content

ref(alerts): add issue_type tag to notifications.sent metric #88063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ def send_notification(event: GroupEvent, futures: Sequence[RuleFuture]) -> None:

key = f"discord:{integration.id}:{channel_id}"

metrics.incr("notifications.sent", instance="discord.notifications", skip_internal=False)
metrics.incr(
"notifications.sent",
instance="discord.notifications",
tags={
"issue_type": event.group.issue_type.slug,
},
skip_internal=False,
)
yield self.future(send_notification, key=key)

def render_label(self) -> str:
Expand Down
9 changes: 8 additions & 1 deletion src/sentry/integrations/msteams/actions/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ def send_notification(event, futures):

key = f"msteams:{integration.id}:{channel}"

metrics.incr("notifications.sent", instance="msteams.notification", skip_internal=False)
metrics.incr(
"notifications.sent",
instance="msteams.notification",
tags={
"issue_type": event.group.issue_type.slug,
},
skip_internal=False,
)
yield self.future(send_notification, key=key)

def render_label(self):
Expand Down
9 changes: 8 additions & 1 deletion src/sentry/integrations/slack/actions/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,14 @@ def send_notification_noa(event: GroupEvent, futures: Sequence[RuleFuture]) -> N

key = f"slack:{integration.id}:{channel}"

metrics.incr("notifications.sent", instance="slack.notification", skip_internal=False)
metrics.incr(
"notifications.sent",
instance="slack.notification",
tags={
"issue_type": event.group.issue_type.slug,
},
skip_internal=False,
)
if features.has("organizations:workflow-engine-trigger-actions", self.project.organization):
yield self.future(send_notification_noa, key=key)
else:
Expand Down
10 changes: 8 additions & 2 deletions src/sentry/mail/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def after(self, event, notification_uuid: str | None = None):
"group_id": group.id,
"notification_uuid": notification_uuid,
}
group = event.group

target_type = ActionTargetType(self.data["targetType"])
target_identifier = self.data.get("targetIdentifier", None)
Expand All @@ -59,7 +58,14 @@ def after(self, event, notification_uuid: str | None = None):
self.logger.info("rule.fail.should_notify", extra=extra)
return

metrics.incr("notifications.sent", instance=self.metrics_slug, skip_internal=False)
metrics.incr(
"notifications.sent",
instance=self.metrics_slug,
tags={
"issue_type": group.issue_type.slug,
},
skip_internal=False,
)
yield self.future(
lambda event, futures: mail_adapter.rule_notify(
event,
Expand Down
9 changes: 8 additions & 1 deletion src/sentry/rules/actions/notify_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,12 @@ def after(
if not safe_execute(plugin.should_notify, group=group, event=event):
continue

metrics.incr("notifications.sent", instance=plugin.slug, skip_internal=False)
metrics.incr(
"notifications.sent",
instance=plugin.slug,
tags={
"issue_type": event.group.issue_type.slug,
},
skip_internal=False,
)
yield self.future(plugin.rule_notify)
18 changes: 16 additions & 2 deletions src/sentry/rules/actions/notify_event_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@ def after(
app = app_service.get_sentry_app_by_slug(slug=service)

if app:
metrics.incr("notifications.sent", instance=app.slug, skip_internal=False)
metrics.incr(
"notifications.sent",
instance=app.slug,
tags={
"issue_type": event.group.issue_type.slug,
},
skip_internal=False,
)
yield self.future(notify_sentry_app, sentry_app=app)

try:
Expand Down Expand Up @@ -198,7 +205,14 @@ def after(
extra["project_id"] = self.project.id
self.logger.info("rules.plugin_notification_sent", extra=extra)

metrics.incr("notifications.sent", instance=plugin.slug, skip_internal=False)
metrics.incr(
"notifications.sent",
instance=plugin.slug,
tags={
"issue_type": event.group.issue_type.slug,
},
skip_internal=False,
)
yield self.future(plugin.rule_notify)

def get_sentry_app_services(self) -> Sequence[RpcSentryAppService]:
Expand Down
Loading