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

feat: Grafana feature health provider #5098

Merged
merged 11 commits into from
Feb 19, 2025
Merged

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Feb 13, 2025

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

  • 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

This PR implements the Grafana (or Prometheus) health provider. Additionally, the feature health framework is refactored:

  • Feature health events can be associated with an external ID. When retrieving events for UI, latest events are now selected per project per feature per environment per provider per external ID. This is done to allow tracking multiple different alerts targeting the same feature.
  • FeatureHealthEvent.created_at can now be set to arbitrary datetime. This is done so we can use datetimes provided by alertmanager.
  • FeatureHealthEvent.reason is now a JSONField with predetermined schema common for all providers. This enables supplying arbitrary number of text and URL data with the feature health event.
  • Feature health providers are now allowed to produce multiple feature health events from one webhook call.
  • A service layer is added to individual providers to potentially allow for more than simple mapping logic.

How did you test this code?

Added integration tests:

  • For a basic scenario.
  • For a case when different alerts hit the same webhook.

@khvn26 khvn26 requested a review from a team as a code owner February 13, 2025 06:53
@khvn26 khvn26 requested review from matthewelwell and removed request for a team February 13, 2025 06:53
Copy link

vercel bot commented Feb 13, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Feb 18, 2025 0:37am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Feb 18, 2025 0:37am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Feb 18, 2025 0:37am

@github-actions github-actions bot added the api Issue related to the REST API label Feb 13, 2025
Copy link
Contributor

github-actions bot commented Feb 13, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-5098 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-5098 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-5098 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-5098 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-5098 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5098 Finished ✅ Results

@github-actions github-actions bot added the feature New feature or request label Feb 13, 2025
Copy link
Contributor

github-actions bot commented Feb 13, 2025

Uffizzi Preview deployment-60871 was deleted.

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Feb 13, 2025
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.46%. Comparing base (5de0b42) to head (7ffe3b6).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5098      +/-   ##
==========================================
+ Coverage   97.45%   97.46%   +0.01%     
==========================================
  Files        1216     1224       +8     
  Lines       42368    42537     +169     
==========================================
+ Hits        41289    41458     +169     
  Misses       1079     1079              

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

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Feb 13, 2025
@khvn26 khvn26 requested a review from a team as a code owner February 13, 2025 16:48
@github-actions github-actions bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Feb 13, 2025
@khvn26 khvn26 force-pushed the feat/grafana-health-provider branch from 4386d9e to ebdd756 Compare February 13, 2025 16:51
@github-actions github-actions bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Feb 13, 2025
@github-actions github-actions bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Feb 13, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Feb 14, 2025
@khvn26 khvn26 requested a review from matthewelwell February 14, 2025 14:14
@matthewelwell
Copy link
Contributor

  1. We should ideally make sure that this field isn't needed in the 'list' endpoint as I believe we'll have to defer it in the queryset, resulting in an N+1 problem.

@khvn26 this is an example of the logic I'm referring to with my comment here

https://github.com/Flagsmith/flagsmith/blob/main/api/permissions/permission_service.py#L147-L152

 - allow health providers to create multiple feature health events
 - add `FeatureHealthEvent.external_id` to track different alerts for one provider
- Add "Advanced Use > Feature Health"
- Add Grafana Feature Health Provider docs
- Improve Grafana Integration docs
- Rename "APM" to "Observability"
@khvn26 khvn26 force-pushed the feat/grafana-health-provider branch from ae4bcaa to 7ffe3b6 Compare February 18, 2025 12:37
@github-actions github-actions bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Feb 18, 2025
@khvn26
Copy link
Member Author

khvn26 commented Feb 18, 2025

@matthewelwell Reverted to TextField to avoid JSONField usage, and removed the squashed migrations.

@khvn26 khvn26 requested a review from matthewelwell February 18, 2025 12:43
@khvn26 khvn26 self-assigned this Feb 18, 2025
@khvn26 khvn26 merged commit 210519e into main Feb 19, 2025
38 checks passed
@khvn26 khvn26 deleted the feat/grafana-health-provider branch February 19, 2025 19:30
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 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants