Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cddef24
feat(profile): add profile command to surface CPU profiling data
BYK Feb 5, 2026
4ac04d6
fix(profile): handle empty profiles and fix percentage calculation
BYK Feb 5, 2026
e757183
feat(profile): add transaction aliases for quick reference
BYK Feb 5, 2026
ce939e1
chore: regenerate SKILL.md for profile commands
BYK Feb 5, 2026
86c2ab1
test: add unit and property tests for transaction aliases
BYK Feb 5, 2026
0e78088
Merge main into feat/profile-command
BYK Feb 6, 2026
456ebf5
chore: regenerate SKILL.md after merge
BYK Feb 6, 2026
7068f49
fix(profile): ensure extractTransactionSegment never returns numeric …
BYK Feb 6, 2026
b14520f
fix(profile): address PR review comments
BYK Feb 6, 2026
f98c5de
chore: regenerate SKILL.md after adding --web flag to profile list
BYK Feb 6, 2026
cb96897
refactor(profile): replace --org/--project flags with positional args
BYK Feb 9, 2026
e6fada5
chore: trigger CI
BYK Feb 9, 2026
dd20ce9
Merge main into feat/profile-command
BYK Feb 9, 2026
f329ace
test(profile): add tests for analyzer, formatters, and URLs
BYK Feb 9, 2026
56ff6ac
test(profile): add command-level tests for list and view
BYK Feb 9, 2026
e44e230
fix(test): use uniqueArray in alias prefix property test
BYK Feb 9, 2026
de41ae2
fix: address all 6 BugBot review comments on profile commands
BYK Feb 9, 2026
44f682e
fix: deduplicate resolveListTarget and rename formatDuration to forma…
BYK Feb 9, 2026
c685648
fix: resolve bare transaction names and formatDurationMs boundary rou…
BYK Feb 9, 2026
ab7d707
fix: exclude current fingerprint in stale alias detection queries
BYK Feb 9, 2026
c83e27b
fix: guard against empty aliases from hyphen/underscore-only transact…
BYK Feb 9, 2026
9ce148d
fix: prefix-based disambiguation to avoid alias overlap, and null-saf…
BYK Feb 9, 2026
0d5c2b3
fix: use nullish() for ProfileFunctionRow fields to accept null from API
BYK Feb 9, 2026
c7d75ab
Merge remote-tracking branch 'origin/main' into feat/profile-command
BYK Feb 17, 2026
b615452
fix(profile): remove unused orgDisplay/projectDisplay from ResolvedPr…
BYK Feb 17, 2026
d45567e
fix(profile): improve output formatting
BYK Feb 17, 2026
ec75c70
feat(profile): add SAMPLES column and docs page
BYK Feb 17, 2026
d35a878
chore: regenerate SKILL.md
github-actions[bot] Feb 17, 2026
2185365
fix(profile): address BugBot review comments
BYK Feb 17, 2026
3817e60
fix(db): use TABLE_SCHEMAS for transaction_aliases and bump schema to v6
BYK Feb 17, 2026
043a7af
fix(profile): align table header columns with data rows
BYK Feb 17, 2026
9a362cc
fix(profile): fix alias pattern and schema repair robustness
BYK Feb 17, 2026
47e63fd
fix(profile): fix invalid --org flag in error suggestion
BYK Feb 17, 2026
16f269c
fix(profile): simplify explicit target resolution and add disambiguat…
BYK Feb 17, 2026
ff4195f
fix(profile): use exhaustive switch check in view.ts default case
BYK Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/content/docs/commands/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The Sentry CLI provides commands for interacting with various Sentry resources.
| [`issue`](./issue/) | Issue tracking |
| [`event`](./event/) | Event inspection |
| [`log`](./log/) | Log viewing and streaming |
| [`profile`](./profile/) | CPU profiling analysis |
| [`api`](./api/) | Direct API access |

## Global Options
Expand Down
155 changes: 155 additions & 0 deletions docs/src/content/docs/commands/profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
title: profile
description: CPU profiling commands for the Sentry CLI
---

Analyze CPU profiling data for your Sentry projects.

## Commands

### `sentry profile list`

List transactions with profiling data, sorted by p75 duration.

```bash
sentry profile list [<org>/<project>]
```

**Arguments:**

| Argument | Description |
|----------|-------------|
| `<org>/<project>` | Target project (optional, auto-detected from DSN) |

**Options:**

| Option | Description | Default |
|--------|-------------|---------|
| `--period` | Time period: `1h`, `24h`, `7d`, `14d`, `30d` | `24h` |
| `-n, --limit` | Maximum transactions to return | `20` |
| `-w, --web` | Open in browser | |
| `--json` | Output as JSON | |

**Example:**

```bash
sentry profile list my-org/backend --period 7d
```

```
Transactions with Profiles in my-org/backend (last 7d):

# ALIAS TRANSACTION SAMPLES p75 p95
─────────────────────────────────────────────────────────────────────────────────────────────────────────
1 u projects/{project_id}/users/ 42 3.8s 5.0s
2 a webhooks/provision/account/ 18 2.7s 2.7s
3 c organizations/{org_id}/code-mappings/ 6 2.1s 2.1s
4 e projects/{project_id}/events/ 291 1.5s 8.6s
5 i organizations/{org_id}/issues/ 541 1.5s 2.8s

Common prefix stripped: /api/0/
Tip: Use 'sentry profile view 1' or 'sentry profile view <alias>' to analyze.
```

Transaction names are shown with common prefixes stripped and middle-truncated for readability. Short aliases are generated for quick reference.

### `sentry profile view`

View CPU profiling analysis for a specific transaction. Displays hot paths, performance percentiles, and optimization recommendations.

```bash
sentry profile view [<org>/<project>] <transaction>
```

**Arguments:**

| Argument | Description |
|----------|-------------|
| `<org>/<project>` | Target project (optional, auto-detected from DSN) |
| `<transaction>` | Transaction index (`1`), alias (`e`), or full name (`/api/users`) |

**Options:**

| Option | Description | Default |
|--------|-------------|---------|
| `--period` | Time period: `1h`, `24h`, `7d`, `14d`, `30d` | `24h` |
| `-n, --limit` | Number of hot paths to show (max 20) | `10` |
| `--allFrames` | Include library/system frames | `false` |
| `-w, --web` | Open in browser | |
| `--json` | Output as JSON | |

**Example using alias from list output:**

```bash
sentry profile view my-org/backend e --period 7d
```

```
/api/0/projects/{project_id}/events/: CPU Profile Analysis (last 7d)
════════════════════════════════════════════════════════════════════════════════

Performance Percentiles
p75: 1.7s p95: 12.1s p99: 12.1s

Hot Paths (Top 10 by CPU time, user code only)
────────────────────────────────────────────────────────────
# Function Location % Time
1 EnvMiddleware.<locals>.EnvMiddleware_impl middleware/env.py:14 7.7%
2 access_log_middlewa…<locals>.middleware middlew…ess_log.py:171 7.7%
3 SubdomainMiddleware.__call__ middlew…ubdomain.py:53 7.7%
4 AIAgentMiddleware.__call__ middlew…ai_agent.py:97 7.6%
5 IntegrationControlMiddleware.__call__ middlew…_control.py:60 7.6%
6 ApiGatewayMiddleware.__call__ hybridc…ddleware.py:19 7.6%
7 DemoModeGuardMiddleware.__call__ middlew…de_guard.py:44 7.6%
8 CustomerDomainMiddleware.__call__ middlew…r_domain.py:97 7.6%
9 StaffMiddleware.__call__ middleware/staff.py:53 7.6%
10 RatelimitMiddleware.__call__ middlew…atelimit.py:57 7.6%
```

**Include library/system frames:**

```bash
sentry profile view my-org/backend e --allFrames --limit 5
```

**JSON output for scripting:**

```bash
sentry profile view my-org/backend e --json | jq '.hotPaths[0].frames[0].name'
```

## Workflow

A typical profiling workflow:

1. **List** transactions to see what has profiling data:
```bash
sentry profile list my-org/backend
```

2. **View** a specific transaction using its alias or index:
```bash
sentry profile view my-org/backend e
```

3. **Investigate** with all frames to see library overhead:
```bash
sentry profile view my-org/backend e --allFrames
```

4. **Open in browser** for the full Sentry UI experience:
```bash
sentry profile view my-org/backend e -w
```

## Transaction References

The `profile view` command accepts three types of transaction references:

| Type | Example | Description |
|------|---------|-------------|
| Index | `1`, `5` | Numeric position from `profile list` output |
| Alias | `e`, `i` | Short alias generated by `profile list` |
| Full name | `/api/users` | Exact transaction name (quoted if it has spaces) |

Aliases and indices are cached from the most recent `profile list` run. If you change the project, org, or period, run `profile list` again to refresh them.
53 changes: 53 additions & 0 deletions plugins/sentry-cli/skills/sentry-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,59 @@ sentry log view my-org/backend 968c763c740cfda8b6728f27fb9e9b01
sentry log list --json | jq '.[] | select(.level == "error")'
```

### Profile

Analyze CPU profiling data

#### `sentry profile list <target>`

List transactions with profiling data

**Flags:**
- `--period <value> - Time period: 1h, 24h, 7d, 14d, 30d - (default: "24h")`
- `-n, --limit <value> - Maximum number of transactions to return - (default: "20")`
- `--json - Output as JSON`
- `-w, --web - Open in browser`

**Examples:**

```bash
sentry profile list [<org>/<project>]

sentry profile list my-org/backend --period 7d
```

#### `sentry profile view <args...>`

View CPU profiling analysis for a transaction

**Flags:**
- `--period <value> - Stats period: 1h, 24h, 7d, 14d, 30d - (default: "24h")`
- `-n, --limit <value> - Number of hot paths to show (max 20) - (default: "10")`
- `--allFrames - Include library/system frames (default: user code only)`
- `--json - Output as JSON`
- `-w, --web - Open in browser`

**Examples:**

```bash
sentry profile view [<org>/<project>] <transaction>

sentry profile view my-org/backend e --period 7d

sentry profile view my-org/backend e --allFrames --limit 5

sentry profile view my-org/backend e --json | jq '.hotPaths[0].frames[0].name'

sentry profile list my-org/backend

sentry profile view my-org/backend e

sentry profile view my-org/backend e --allFrames

sentry profile view my-org/backend e -w
```

### Trace

View distributed traces
Expand Down
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { logRoute } from "./commands/log/index.js";
import { listCommand as logListCommand } from "./commands/log/list.js";
import { orgRoute } from "./commands/org/index.js";
import { listCommand as orgListCommand } from "./commands/org/list.js";
import { profileRoute } from "./commands/profile/index.js";
import { projectRoute } from "./commands/project/index.js";
import { listCommand as projectListCommand } from "./commands/project/list.js";
import { repoRoute } from "./commands/repo/index.js";
Expand All @@ -42,6 +43,7 @@ export const routes = buildRouteMap({
issue: issueRoute,
event: eventRoute,
log: logRoute,
profile: profileRoute,
trace: traceRoute,
api: apiCommand,
issues: issueListCommand,
Expand Down
1 change: 1 addition & 0 deletions src/commands/event/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export function parsePositionalArgs(args: string[]): {

/**
* Resolved target type for event commands.
* Uses ResolvedTarget from resolve-target.ts.
* @internal Exported for testing
*/
export type ResolvedEventTarget = {
Expand Down
19 changes: 19 additions & 0 deletions src/commands/profile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { buildRouteMap } from "@stricli/core";
import { listCommand } from "./list.js";
import { viewCommand } from "./view.js";

export const profileRoute = buildRouteMap({
routes: {
list: listCommand,
view: viewCommand,
},
docs: {
brief: "Analyze CPU profiling data",
fullDescription:
"View and analyze CPU profiling data from your Sentry projects.\n\n" +
"Commands:\n" +
" list List transactions with profiling data\n" +
" view View CPU profiling analysis for a transaction",
hideRoute: {},
},
});
Loading
Loading