Skip to content
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
4 changes: 2 additions & 2 deletions src/sentry/integrations/slack/unfurl/metric_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ def map_metric_alert_query_args(url: str, args: Mapping[str, str | None]) -> Map


metric_alerts_link_regex = re.compile(
r"^https?\://(?#url_prefix)[^/]+/organizations/(?P<org_slug>[^/]+)/alerts/rules/details/(?P<alert_rule_id>\d+)"
r"^https?\://(?#url_prefix)[^/]+/organizations/(?P<org_slug>[^/]+)/issues/alerts/rules/details/(?P<alert_rule_id>\d+)"
)

customer_domain_metric_alerts_link_regex = re.compile(
r"^https?\://(?P<org_slug>[^/]+?)\.(?#url_prefix)[^/]+/alerts/rules/details/(?P<alert_rule_id>\d+)"
r"^https?\://(?P<org_slug>[^/]+?)\.(?#url_prefix)[^/]+/issues/alerts/rules/details/(?P<alert_rule_id>\d+)"
)
Comment thread
malwilley marked this conversation as resolved.

metric_alert_handler = Handler(
Expand Down
38 changes: 23 additions & 15 deletions tests/sentry/integrations/slack/test_unfurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
),
(
"https://sentry.io/organizations/org1/alerts/rules/details/12345/",
(None, None),
),
(
"https://org1.sentry.io/alerts/rules/details/12345/",
(None, None),
),
(
"https://sentry.io/organizations/org1/issues/alerts/rules/details/12345/",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -58,7 +66,7 @@
),
),
(
"https://org1.sentry.io/alerts/rules/details/12345/",
"https://org1.sentry.io/issues/alerts/rules/details/12345/",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -72,7 +80,7 @@
),
),
(
"https://sentry.io/organizations/org1/alerts/rules/details/12345/?alert=1337",
"https://sentry.io/organizations/org1/issues/alerts/rules/details/12345/?alert=1337",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -86,7 +94,7 @@
),
),
(
"https://org1.sentry.io/alerts/rules/details/12345/?alert=1337",
"https://org1.sentry.io/issues/alerts/rules/details/12345/?alert=1337",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -100,7 +108,7 @@
),
),
(
"https://sentry.io/organizations/org1/alerts/rules/details/12345/?period=14d",
"https://sentry.io/organizations/org1/issues/alerts/rules/details/12345/?period=14d",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -114,7 +122,7 @@
),
),
(
"https://org1.sentry.io/alerts/rules/details/12345/?period=14d",
"https://org1.sentry.io/issues/alerts/rules/details/12345/?period=14d",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -128,7 +136,7 @@
),
),
(
"https://sentry.io/organizations/org1/alerts/rules/details/12345/?end=2022-05-05T06%3A05%3A52&start=2022-05-04T00%3A46%3A19",
"https://sentry.io/organizations/org1/issues/alerts/rules/details/12345/?end=2022-05-05T06%3A05%3A52&start=2022-05-04T00%3A46%3A19",
(
LinkType.METRIC_ALERT,
{
Expand All @@ -142,7 +150,7 @@
),
),
(
"https://org1.sentry.io/alerts/rules/details/12345/?end=2022-05-05T06%3A05%3A52&start=2022-05-04T00%3A46%3A19",
"https://org1.sentry.io/issues/alerts/rules/details/12345/?end=2022-05-05T06%3A05%3A52&start=2022-05-04T00%3A46%3A19",
(
LinkType.METRIC_ALERT,
{
Expand Down Expand Up @@ -295,7 +303,7 @@ def test_unfurl_metric_alert(self) -> None:

links = [
UnfurlableUrl(
url=f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{incident.alert_rule.id}/?alert={incident.identifier}",
url=f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{incident.alert_rule.id}/?alert={incident.identifier}",
args={
"org_slug": self.organization.slug,
"alert_rule_id": incident.alert_rule.id,
Expand All @@ -309,7 +317,7 @@ def test_unfurl_metric_alert(self) -> None:
unfurls = link_handlers[LinkType.METRIC_ALERT].fn(self.integration, links)
assert (
links[0].url
== f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{incident.alert_rule.id}/?alert={incident.identifier}"
== f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{incident.alert_rule.id}/?alert={incident.identifier}"
)
assert (
unfurls[links[0].url]
Expand All @@ -332,7 +340,7 @@ def test_unfurl_metric_alerts_chart(self, mock_generate_chart: MagicMock) -> Non
alert_rule_trigger=trigger, triggered_for_incident=incident
)

url = f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
url = f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
links = [
UnfurlableUrl(
url=url,
Expand Down Expand Up @@ -384,7 +392,7 @@ def test_unfurl_metric_alerts_chart_transaction(self, mock_generate_chart: Magic
date_started=timezone.now() - timedelta(minutes=2),
)

url = f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
url = f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
links = [
UnfurlableUrl(
url=url,
Expand Down Expand Up @@ -442,7 +450,7 @@ def test_unfurl_metric_alerts_chart_eap_spans(self, mock_generate_chart: MagicMo
alert_rule_trigger=trigger, triggered_for_incident=incident
)

url = f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
url = f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
links = [
UnfurlableUrl(
url=url,
Expand Down Expand Up @@ -502,7 +510,7 @@ def test_unfurl_metric_alerts_chart_eap_spans_events_stats_call(
date_started=timezone.now() - timedelta(minutes=2),
)

url = f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
url = f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
links = [
UnfurlableUrl(
url=url,
Expand Down Expand Up @@ -551,7 +559,7 @@ def test_unfurl_metric_alerts_chart_eap_ourlogs_events_stats_call(
date_started=timezone.now() - timedelta(minutes=2),
)

url = f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
url = f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{alert_rule.id}/?alert={incident.identifier}"
links = [
UnfurlableUrl(
url=url,
Expand Down Expand Up @@ -590,7 +598,7 @@ def test_unfurl_metric_alerts_chart_crash_free(self, mock_generate_chart: MagicM
threshold_period=1,
)

url = f"https://sentry.io/organizations/{self.organization.slug}/alerts/rules/details/{alert_rule.id}/"
url = f"https://sentry.io/organizations/{self.organization.slug}/issues/alerts/rules/details/{alert_rule.id}/"
links = [
UnfurlableUrl(
url=url,
Expand Down
Loading