feat(uptime): Add AI-powered assertion suggestions backend#108377
feat(uptime): Add AI-powered assertion suggestions backend#108377
Conversation
|
🚨 Warning: This pull request contains Frontend and Backend changes! It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently. Have questions? Please ask in the |
|
The only frontend change here is a single line added to The actual frontend UI changes (button, drawer, suggestion cards) are in the stacked PR #108378. |
Add a new endpoint that uses Seer's LLM proxy to generate assertion
suggestions for uptime monitors based on preview check responses.
- New endpoint: POST /organizations/{org}/uptime-assertion-suggestions/
- Uses has_seer_access() to respect both gen-ai-features flag and
hide_ai_features org opt-out
- Parses preview check responses and sends to Seer for analysis
- Converts Seer suggestions to uptime checker assertion JSON format
- Rate limited to 1 req/5s per user, 10 req/60s per org
- Includes comprehensive unit tests
2fbd02d to
5fdd512
Compare
## Summary
- Adds a new API endpoint `POST
/api/0/organizations/{org}/uptime-assertion-suggestions/` that runs a
preview check and uses Seer's LLM proxy to analyze the HTTP response and
suggest useful monitoring assertions
- Introduces `seer_assertions.py` module with prompt engineering,
structured output parsing (via Gemini), and conversion logic to
translate AI suggestions into the uptime checker's assertion JSON format
- Gates the endpoint behind `gen-ai-features` +
`uptime-runtime-assertions` flags and respects `hide_ai_features`
organization opt-out via `has_seer_access()`
- Includes rate limiting (1 req/5s per user, 10 req/60s per org) since
each call hits both the uptime checker and Seer
### New files
-
`src/sentry/uptime/endpoints/organization_uptime_assertion_suggestions.py`
— API endpoint
- `src/sentry/uptime/seer_assertions.py` — Seer integration, prompt,
parsing, assertion conversion
- `tests/sentry/uptime/test_seer_assertions.py` — unit tests for
parsing, prompting, and conversion logic
## Test plan
- [ ] Unit tests pass: `pytest
tests/sentry/uptime/test_seer_assertions.py`
- [ ] Endpoint integration: verify 403 when flags disabled, 200 with
valid preview check data
- [ ] Verify rate limiting behaves correctly
- [ ] Confirm `hide_ai_features` org option blocks access even when
flags are enabled
Depends on: #108178 (feature flag registration, already merged)
Replaces: #108377 (closed due to force-push race)
---------
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
## Summary
- Adds a new API endpoint `POST
/api/0/organizations/{org}/uptime-assertion-suggestions/` that runs a
preview check and uses Seer's LLM proxy to analyze the HTTP response and
suggest useful monitoring assertions
- Introduces `seer_assertions.py` module with prompt engineering,
structured output parsing (via Gemini), and conversion logic to
translate AI suggestions into the uptime checker's assertion JSON format
- Gates the endpoint behind `gen-ai-features` +
`uptime-runtime-assertions` flags and respects `hide_ai_features`
organization opt-out via `has_seer_access()`
- Includes rate limiting (1 req/5s per user, 10 req/60s per org) since
each call hits both the uptime checker and Seer
### New files
-
`src/sentry/uptime/endpoints/organization_uptime_assertion_suggestions.py`
— API endpoint
- `src/sentry/uptime/seer_assertions.py` — Seer integration, prompt,
parsing, assertion conversion
- `tests/sentry/uptime/test_seer_assertions.py` — unit tests for
parsing, prompting, and conversion logic
## Test plan
- [ ] Unit tests pass: `pytest
tests/sentry/uptime/test_seer_assertions.py`
- [ ] Endpoint integration: verify 403 when flags disabled, 200 with
valid preview check data
- [ ] Verify rate limiting behaves correctly
- [ ] Confirm `hide_ai_features` org option blocks access even when
flags are enabled
Depends on: #108178 (feature flag registration, already merged)
Replaces: #108377 (closed due to force-push race)
---------
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Summary
POST /api/0/organizations/{org}/uptime-assertion-suggestions/that runs a preview check and uses Seer's LLM proxy to analyze the HTTP response and suggest useful monitoring assertionsseer_assertions.pymodule with prompt engineering, structured output parsing (via Gemini), and conversion logic to translate AI suggestions into the uptime checker's assertion JSON formatgen-ai-features+uptime-runtime-assertionsflags and respectshide_ai_featuresorganization opt-out viahas_seer_access()New files
src/sentry/uptime/endpoints/organization_uptime_assertion_suggestions.py— API endpointsrc/sentry/uptime/seer_assertions.py— Seer integration, prompt, parsing, assertion conversiontests/sentry/uptime/test_seer_assertions.py— unit tests for parsing, prompting, and conversion logicTest plan
pytest tests/sentry/uptime/test_seer_assertions.pyhide_ai_featuresorg option blocks access even when flags are enabledDepends on: #108178 (feature flag registration, already merged)