Skip to content

Commit 880e6d4

Browse files
authored
chore(slack): track timeout errors from sdk WebClient (#73546)
1 parent ffd0389 commit 880e6d4

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/sentry/integrations/slack/sdk_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ def wrapped(*args, **kwargs):
7676
else:
7777
logger.info("slack_sdk.missing_error_response", extra={"error": str(e)})
7878
raise
79+
except TimeoutError:
80+
metrics.incr(
81+
SLACK_DATADOG_METRIC,
82+
sample_rate=1.0,
83+
tags={"status": "timeout"},
84+
)
85+
raise
7986

8087
return response
8188

tests/sentry/integrations/slack/test_sdk_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,19 @@ def test_api_call_error(self, mock_api_call, mock_metrics):
6969
sample_rate=1.0,
7070
tags={"ok": False, "status": 500},
7171
)
72+
73+
@patch("sentry.integrations.slack.sdk_client.metrics")
74+
@patch("slack_sdk.web.client.WebClient._perform_urllib_http_request")
75+
def test_api_call_timeout_error(self, mock_api_call, mock_metrics):
76+
mock_api_call.side_effect = TimeoutError()
77+
78+
client = SlackSdkClient(integration_id=self.integration.id)
79+
80+
with pytest.raises(TimeoutError):
81+
client.chat_postMessage(channel="#announcements", text="hello")
82+
83+
mock_metrics.incr.assert_called_with(
84+
SLACK_DATADOG_METRIC,
85+
sample_rate=1.0,
86+
tags={"status": "timeout"},
87+
)

0 commit comments

Comments
 (0)