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

fix: API usage alerting in production #3507

Merged
merged 28 commits into from
Mar 28, 2024

Conversation

zachaysan
Copy link
Contributor

@zachaysan zachaysan commented Feb 28, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

In order to address #3461 two main issues were handled. First, an incorrectly implemented InfluxDB query was fixed in order to get the full API usage counts in a single scalar. Second, a local evaluation mode Flagsmith client was introduced in order to allowlist organisations into alerting so that any given mistake in the API alerting code won't disrupt too many users.

How did you test this code?

The API usage code was tested against the staging InfluxDB setup with a date range window set to about a year to gather the most amount of data. Thousands of organisations were tested without the same failure once the fix was implemented.

The local evaluation Flagsmith client code was tested locally with settings variables set to appropriate values. During testing an issue with local evaluation cropped up where flags were not present if the method call happened before the local evaluation cache had been set, so this was temporarily worked around with a small sleep on the client's instantiation.

Copy link

vercel bot commented Feb 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2024 6:36pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2024 6:36pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2024 6:36pm

@github-actions github-actions bot added the api Issue related to the REST API label Feb 28, 2024
@zachaysan zachaysan changed the title Fix/api usage alerting in production fix: API usage alerting in production Feb 28, 2024
Copy link
Contributor

github-actions bot commented Feb 28, 2024

Uffizzi Preview deployment-48447 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.86%. Comparing base (8d79cb1) to head (833a17a).
Report is 14 commits behind head on main.

❗ Current head 833a17a differs from pull request most recent head 136bdd1. Consider uploading reports for the commit 136bdd1 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3507      +/-   ##
==========================================
- Coverage   95.86%   95.86%   -0.01%     
==========================================
  Files        1099     1099              
  Lines       34282    34376      +94     
==========================================
+ Hits        32864    32954      +90     
- Misses       1418     1422       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

zachaysan and others added 2 commits March 18, 2024 13:35
Co-authored-by: Kim Gustyr <kim.gustyr@flagsmith.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants