feat(observability): shared severity-threshold resolver for Sentry + PagerDuty - #5704
Merged
Merged
Conversation
…PagerDuty Every self-host observability capture point fired unconditionally before this: captureError/captureReviewFailure always forwarded to Sentry, and forwardStructuredLogToSentry hardcoded an error/fatal-only cutoff with no way to configure it. The one severity-threshold precedent (PagerDuty's PAGERDUTY_MIN_SEVERITY/PAGERDUTY_REPO_MIN_SEVERITY) was scoped to paging only, not general Sentry/log verbosity. Extracts a shared resolveSeverityThreshold (src/services/severity-threshold.ts): global env var + per-repo JSON-map override, the same precedence every other alerting channel (Discord, PagerDuty) already uses. Wires it into all three sentry.ts capture paths (SENTRY_MIN_SEVERITY / SENTRY_REPO_MIN_SEVERITY) and retrofits notify-pagerduty.ts's own resolver to delegate to the shared one instead of keeping a parallel copy. Default threshold (error) is byte-identical to every path's pre-existing behavior; an operator can lower a specific repo's threshold to warning/info for full visibility while actively debugging it, without raising Sentry noise everywhere else. Regenerated the self-host env reference for the 2 new vars. Closes #5119
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
loopover-ui | e73dea7 | Commit Preview URL Branch Preview URL |
Jul 14 2026, 06:01 AM |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5704 +/- ##
=======================================
Coverage 95.05% 95.05%
=======================================
Files 580 581 +1
Lines 46127 46157 +30
Branches 14793 14808 +15
=======================================
+ Hits 43845 43874 +29
Misses 1523 1523
- Partials 759 760 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
captureError/captureReviewFailurealways forwarded to Sentry, andforwardStructuredLogToSentryhardcoded an error/fatal-only cutoff with no way to configure it. The one severity-threshold precedent (PagerDuty'sPAGERDUTY_MIN_SEVERITY/PAGERDUTY_REPO_MIN_SEVERITY) was scoped to paging only.resolveSeverityThreshold(src/services/severity-threshold.ts): global env var + per-repo JSON-map override, the same precedence every other alerting channel (Discord, PagerDuty) already uses.sentry.tscapture paths via newSENTRY_MIN_SEVERITY/SENTRY_REPO_MIN_SEVERITYvars, and retrofitsnotify-pagerduty.ts's own resolver to delegate to the shared one (keptPagerDutySeverityas a type alias soops-wire.ts's existing import is untouched).error) is byte-identical to every capture path's pre-existing behavior — an operator who never touches these vars sees no change. Lowering a specific repo's threshold (e.g. toinfo) surfaces routine structured logs from that repo while it's under active investigation, without raising Sentry noise everywhere else.npm run selfhost:env-reference) for the 2 new vars.Test plan
test/unit/severity-threshold.test.ts(new) — the shared resolver: repo-map precedence, case-insensitivity, malformed-map handling, empty-repo fallback, process.env fallbacktest/unit/selfhost-sentry.test.ts— 13 new regression tests: default-unchanged behavior for all 3 capture paths, per-repo suppression/isolation, global-threshold fallback for non-repo-scoped captures, lowering a repo's threshold surfaces warning/info logs, an unrecognized level (e.g."audit") never gets promoted to error gradetest/unit/notify-pagerduty.test.ts+test/unit/ops-wire.test.ts— unaffected, still green (confirms thePagerDutySeverityalias didn't break anything)npm run test:ci+npm audit --audit-level=moderate) green: 831 test files passed, 0 failedCloses #5119