Skip to content
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

🔧 chore(discord): change rate limits to halt for SLOs #83656

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

iamrajjoshi
Copy link
Member

one org has a extremely noisy alert (~4k fires in a single week) and its been severely ratelimited by discord. this however impacts our slos since we currently record rate limits as failures instead of halts.

also wrote some basic test cases for discord incident alert handler b/c we didn't have any 😬

@iamrajjoshi iamrajjoshi self-assigned this Jan 17, 2025
@iamrajjoshi iamrajjoshi requested review from a team as code owners January 17, 2025 17:29
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 17, 2025
lifecycle.add_extras(
{
"incident_id": incident.id,
"channel_id": channel,
}
)
lifecycle.record_failure(error)
if isinstance(error, ApiRateLimitedError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I largely agree that this is a user-caused issue now, this might be problematic for users with larger orgs in the future if they decide to use the discord integration. We don't have to address this now, but we may want to consider having some mechanism to backlog and batch in the future (if possible).

Comment on lines +81 to +86
responses.add(
method=responses.POST,
url=f"{DISCORD_BASE_URL}{MESSAGE_URL.format(channel_id=self.channel_id)}",
json={},
status=200,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this if the setup is already setting a mock response, and we're asserting that it's not called?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

Comment on lines 90 to 92
@mock.patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
def assert_lifecycle_metrics_halt_for_rate_limit(self, mock_record_event, mock_send_message):
assert_slo_metric(mock_record_event, EventLifecycleOutcome.HALTED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this defined, but I don't see this used anywhere.

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 95.29412% with 4 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ts/sentry/integrations/discord/test_issue_alert.py 57.14% 3 Missing ⚠️
...ations/discord/actions/issue_alert/notification.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #83656    +/-   ##
========================================
  Coverage   87.57%   87.58%            
========================================
  Files        9492     9492            
  Lines      539296   539414   +118     
  Branches    21219    21219            
========================================
+ Hits       472310   472460   +150     
+ Misses      66637    66605    -32     
  Partials      349      349            

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants