-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat(status): add sentry status command group
#1494
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
Open
jared-outpost
wants to merge
10
commits into
main
Choose a base branch
from
issue-1493-sentry-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e18a79d
feat(status): add `sentry status` command group
jared-outpost[bot] b185f43
test: register status group in completions property test
jared-outpost[bot] 0b93307
feat(status): support self-hosted /_health/ probe
jared-outpost[bot] 8cf5255
fix(status): route status.sentry.io to Statuspage summary + fix lint
jared-outpost[bot] 4aa739c
feat(status): use 5 s timeout for /_health/ probe
jared-outpost[bot] 635f09e
fix(status): drop digit separator on 4-digit health timeout
jared-outpost[bot] f5c6364
fix(status): treat any host containing "status" as Statuspage
jared-outpost[bot] e511ac1
chore: regenerate docs
github-actions[bot] 7e03ef3
fix(status): swallow non-ApiError failures from misclassified hosts
jared-outpost[bot] 9ec17f2
fix(status): surface subsystem failures + drop false-outage fallback
jared-outpost[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
|
|
||
|
|
||
| ## Examples | ||
|
|
||
| ```bash | ||
| # Show the current status of Sentry's services | ||
| sentry status | ||
| ``` | ||
|
|
||
| ``` | ||
| ✓ All Systems Operational | ||
|
|
||
| ### Components | ||
|
|
||
| ● Dashboard — Operational | ||
| ● US Error Ingestion — Operational | ||
|
|
||
| See https://status.sentry.io for full details. | ||
| ``` | ||
|
|
||
| ```bash | ||
| # Get machine-readable status (useful in scripts) | ||
| sentry status --json | ||
| ``` | ||
|
|
||
| ```bash | ||
| # Check a self-hosted or regional status page (Statuspage CNAME) | ||
| sentry status --url https://status.acme.com | ||
| ``` |
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
34 changes: 34 additions & 0 deletions
34
packages/cli/plugins/sentry-cli/skills/sentry-cli/references/status.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --- | ||
| name: sentry-cli-status | ||
| version: 0.44.0-dev.0 | ||
| description: Check Sentry service status | ||
| requires: | ||
| bins: ["sentry"] | ||
| auth: true | ||
| --- | ||
|
|
||
| # Status Commands | ||
|
|
||
| Check Sentry service status | ||
|
|
||
| ### `sentry status show` | ||
|
|
||
| Show Sentry service status | ||
|
|
||
| **Flags:** | ||
| - `--url <value> - Status page base URL to query - (default: "https://status.sentry.io")` | ||
|
|
||
| **Examples:** | ||
|
|
||
| ```bash | ||
| # Show the current status of Sentry's services | ||
| sentry status | ||
|
|
||
| # Get machine-readable status (useful in scripts) | ||
| sentry status --json | ||
|
|
||
| # Check a self-hosted or regional status page (Statuspage CNAME) | ||
| sentry status --url https://status.acme.com | ||
| ``` | ||
|
|
||
| All commands also support `--json`, `--fields`, `--help`, `--log-level`, and `--verbose` flags. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * sentry status | ||
| * | ||
| * Check the status of Sentry's services. | ||
| */ | ||
|
|
||
| import { buildRouteMap } from "../../lib/route-map.js"; | ||
| import { showCommand } from "./show.js"; | ||
|
|
||
| export const statusRoute = buildRouteMap({ | ||
| routes: { | ||
| show: showCommand, | ||
| }, | ||
| defaultCommand: "show", | ||
| docs: { | ||
| brief: "Check Sentry service status", | ||
| fullDescription: | ||
| "Report the current status of Sentry's services using the public " + | ||
| "status page (https://status.sentry.io) as the backend.\n\n" + | ||
| "Running `sentry status` with no subcommand shows the current status.", | ||
| hideRoute: {}, | ||
| }, | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /** | ||
| * sentry status show | ||
| * | ||
| * Report the current status of Sentry's services by querying the public | ||
| * Statuspage backend at https://status.sentry.io. Useful when the Sentry API | ||
| * is degraded and you want to know whether the problem is on Sentry's side. | ||
| */ | ||
|
|
||
| import type { SentryContext } from "../../context.js"; | ||
| import { | ||
| fetchSentryStatus, | ||
| SENTRY_STATUS_PAGE_URL, | ||
| } from "../../lib/api/status-page.js"; | ||
| import { buildCommand } from "../../lib/command.js"; | ||
| import { formatSentryStatus } from "../../lib/formatters/human.js"; | ||
| import { CommandOutput } from "../../lib/formatters/output.js"; | ||
|
|
||
| type ShowFlags = { | ||
| readonly json: boolean; | ||
| readonly url: string; | ||
| readonly fields?: string[]; | ||
| }; | ||
|
|
||
| export const showCommand = buildCommand({ | ||
| // Checking the public status page requires no Sentry credentials. | ||
| auth: false, | ||
| docs: { | ||
| brief: "Show Sentry service status", | ||
| fullDescription: | ||
| "Report the current status of Sentry's services using the public " + | ||
| "status page (https://status.sentry.io) as the backend.\n\n" + | ||
| "This works even when the Sentry API is degraded or unreachable, so " + | ||
| "you can tell whether an issue is on Sentry's side. Point `--url` at a " + | ||
| "different Statuspage instance to check a self-hosted or regional page.", | ||
| }, | ||
| output: { human: formatSentryStatus }, | ||
| parameters: { | ||
| flags: { | ||
| url: { | ||
| kind: "parsed", | ||
| parse: String, | ||
| brief: "Status page base URL to query", | ||
| default: SENTRY_STATUS_PAGE_URL, | ||
| }, | ||
| }, | ||
| }, | ||
| async *func(this: SentryContext, flags: ShowFlags) { | ||
| const status = await fetchSentryStatus(flags.url); | ||
| yield new CommandOutput(status); | ||
|
|
||
| if (status.indicator !== "none") { | ||
| return { | ||
| hint: `Run \`sentry status\` again to refresh, or open ${status.url}`, | ||
| }; | ||
| } | ||
| }, | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| /** | ||
| * Statuspage.io API client for Sentry's public status page. | ||
| * | ||
| * Sentry's status page (https://status.sentry.io) is hosted on Statuspage.io, | ||
| * which exposes a stable JSON summary at `/api/v2/summary.json`. This module | ||
| * fetches and shapes that payload for the `sentry status` command. | ||
| * | ||
| * The request is bounded by an explicit timeout so a status check never hangs, | ||
| * which is the whole point of the command — it is meant to work even while the | ||
| * Sentry API itself is degraded. | ||
| */ | ||
|
|
||
| import { customFetch } from "../custom-ca.js"; | ||
| import { ApiError } from "../errors.js"; | ||
|
|
||
| /** Default Sentry status page base URL. */ | ||
| export const SENTRY_STATUS_PAGE_URL = "https://status.sentry.io"; | ||
|
|
||
| /** Bound the request so a status check never hangs, even during an outage. */ | ||
| const STATUS_REQUEST_TIMEOUT_MS = 10_000; | ||
|
|
||
| /** Shorter timeout for the lightweight /_health/ probe (self-hosted or sentry.io). */ | ||
| const HEALTH_REQUEST_TIMEOUT_MS = 5000; | ||
|
|
||
| /** Matches one or more trailing slashes so base URLs normalize cleanly. */ | ||
| const TRAILING_SLASHES = /\/+$/; | ||
|
|
||
| /** Overall indicator reported by Statuspage. */ | ||
| export type StatusIndicator = | ||
| | "none" | ||
| | "minor" | ||
| | "major" | ||
| | "critical" | ||
| | "maintenance"; | ||
|
|
||
| /** Per-component operational status reported by Statuspage. */ | ||
| export type ComponentStatus = | ||
| | "operational" | ||
| | "degraded_performance" | ||
| | "partial_outage" | ||
| | "major_outage" | ||
| | "under_maintenance"; | ||
|
|
||
| /** A single service component on the status page. */ | ||
| export type StatusComponent = { | ||
| readonly name: string; | ||
| readonly status: ComponentStatus; | ||
| }; | ||
|
|
||
| /** An ongoing or recent incident. */ | ||
| export type StatusIncident = { | ||
| readonly name: string; | ||
| readonly status: string; | ||
| readonly impact: string; | ||
| readonly shortlink: string; | ||
| }; | ||
|
|
||
| /** Structured status data: JSON output shape and human-formatter input. */ | ||
| export type SentryStatus = { | ||
| /** Overall indicator and human-readable description. */ | ||
| readonly indicator: StatusIndicator; | ||
| readonly description: string; | ||
| /** Status page URL the data was fetched from. */ | ||
| readonly url: string; | ||
| /** All service components with their current status. */ | ||
| readonly components: readonly StatusComponent[]; | ||
| /** Unresolved incidents currently shown on the status page. */ | ||
| readonly incidents: readonly StatusIncident[]; | ||
| }; | ||
|
|
||
| /** Shape of the Statuspage `/api/v2/summary.json` response we consume. */ | ||
| type SummaryResponse = { | ||
| page?: { url?: string }; | ||
| status?: { indicator?: string; description?: string }; | ||
| components?: Array<{ name?: string; status?: string; group?: boolean }>; | ||
| incidents?: Array<{ | ||
| name?: string; | ||
| status?: string; | ||
| impact?: string; | ||
| shortlink?: string; | ||
| }>; | ||
| }; | ||
|
|
||
| /** | ||
| * Fetch the current Sentry service status from a Statuspage summary endpoint. | ||
| * | ||
| * @param baseUrl - Status page base URL (defaults to status.sentry.io). Pass a | ||
| * custom URL to point at a self-hosted or regional Statuspage instance. | ||
| */ | ||
| export function fetchSentryStatus( | ||
| baseUrl: string = SENTRY_STATUS_PAGE_URL | ||
| ): Promise<SentryStatus> { | ||
| const normalized = baseUrl.replace(TRAILING_SLASHES, ""); | ||
|
|
||
| // Statuspage hosts (statuspage.io) use the /api/v2/summary.json flow. | ||
| // All other hosts (self-hosted) are probed via the generic /_health/ endpoint. | ||
| let parsedUrl: URL | undefined; | ||
| try { | ||
| parsedUrl = new URL(normalized); | ||
| } catch { | ||
| parsedUrl = undefined; | ||
| } | ||
| const host = parsedUrl?.hostname.toLowerCase() ?? ""; | ||
| // Sentry's public status page (status.sentry.io) is a Statuspage instance, | ||
| // as are any *.statuspage.io hosts and common CNAMEs containing "status" | ||
| // (status.example.com, statuspage.acme.com, …). Everything else falls back | ||
| // to the lightweight self-hosted /_health/ probe. | ||
| const isStatuspageHost = | ||
| host === "status.sentry.io" || | ||
| host.endsWith(".statuspage.io") || | ||
| host.includes("status"); | ||
|
sentry[bot] marked this conversation as resolved.
|
||
|
|
||
| return isStatuspageHost | ||
| ? fetchStatuspageSummary(normalized) | ||
| : probeSelfHostedHealth(normalized); | ||
| } | ||
|
|
||
| /** Fetch and shape a Statuspage `/api/v2/summary.json` response. */ | ||
| async function fetchStatuspageSummary( | ||
| normalized: string | ||
| ): Promise<SentryStatus> { | ||
| const endpoint = `${normalized}/api/v2/summary.json`; | ||
|
|
||
| const response = await customFetch(endpoint, { | ||
| signal: AbortSignal.timeout(STATUS_REQUEST_TIMEOUT_MS), | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new ApiError( | ||
| "Failed to fetch Sentry status", | ||
| response.status, | ||
| await response.text(), | ||
| endpoint | ||
| ); | ||
| } | ||
|
|
||
| const summary = (await response.json()) as SummaryResponse; | ||
|
|
||
| const components: StatusComponent[] = (summary.components ?? []) | ||
| // Group headers carry no operational status of their own. | ||
| .filter((c) => !c.group && typeof c.name === "string") | ||
| .map((c) => ({ | ||
| name: c.name as string, | ||
| status: (c.status as ComponentStatus) ?? "operational", | ||
| })); | ||
|
|
||
| const incidents: StatusIncident[] = (summary.incidents ?? []).map((i) => ({ | ||
| name: i.name ?? "Unnamed incident", | ||
| status: i.status ?? "unknown", | ||
| impact: i.impact ?? "none", | ||
| shortlink: i.shortlink ?? normalized, | ||
| })); | ||
|
|
||
| return { | ||
| indicator: (summary.status?.indicator as StatusIndicator) ?? "none", | ||
| description: summary.status?.description ?? "Unknown", | ||
| url: summary.page?.url ?? normalized, | ||
| components, | ||
| incidents, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Probe a self-hosted Sentry's `/_health/` endpoint. Never throws — network or | ||
| * HTTP failures are reported as a synthetic "major" status so the command can | ||
| * still render something useful when the instance is down. | ||
| * | ||
| * Uses `?full=1` so the check exercises every subsystem (Postgres, Redis, | ||
| * Celery, …) rather than the bare liveness probe: without it Sentry returns | ||
| * HTTP 200 whenever the web process is up, masking real backend outages. | ||
| */ | ||
| async function probeSelfHostedHealth( | ||
| normalized: string | ||
| ): Promise<SentryStatus> { | ||
| const healthEndpoint = `${normalized}/_health/?full=1`; | ||
| try { | ||
| const resp = await customFetch(healthEndpoint, { | ||
| signal: AbortSignal.timeout(HEALTH_REQUEST_TIMEOUT_MS), | ||
| }); | ||
|
|
||
| return { | ||
| indicator: resp.ok ? "none" : "major", | ||
| description: resp.statusText || (resp.ok ? "OK" : `HTTP ${resp.status}`), | ||
| url: normalized, | ||
| components: [], | ||
| incidents: [], | ||
| }; | ||
|
jared-outpost[bot] marked this conversation as resolved.
|
||
| } catch (err) { | ||
| return { | ||
| indicator: "major", | ||
| description: err instanceof Error ? err.message : String(err), | ||
| url: normalized, | ||
| components: [], | ||
| incidents: [], | ||
| }; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not better to do a DNS look up or direct API call test rather than a set of known URLs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heuristic (any host containing "status") is intentionally loose to support common Statuspage CNAMEs (status.acme.com, statuspage.example.com, …) while still excluding obvious non-Statuspage hosts. The crash-safety net already exists: any non-ApiError from a misclassified host falls back to the synthetic health status. Explicit ApiErrors still propagate so CLI error handling is unchanged.
Items 1 (per-endpoint timeouts) and 3 (auto status check + 5xx suppression) are acknowledged as follow-up work. They are cross-cutting changes that would make this PR much larger and shift its focus away from the bounded deliverable (the
sentry statuscommand group). Happy to open separate issues/PRs for them if you'd like them tracked.