feat(reports): add memory commitment chart to database report DEBUG-119#46435
Conversation
Surfaces a separate memory commitment chart between the existing memory usage and swap charts, showing committed memory against the kernel commit limit. Helps users spot overcommitment and OOM risk without overloading the main memory chart. Backend support: supabase/platform#33321 Linear: DEBUG-119 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR introduces RAM commitment metrics for database observability. The API types are extended to accept ChangesRAM Commitment Metrics Support
Sequence DiagramsequenceDiagram
participant DatabasePage as Database<br/>Observability Page
participant FeatureFlags as Feature Flags
participant ReportBuilder as getReportAttributesV2
participant ChartConfig as Chart Configuration
DatabasePage->>FeatureFlags: useFlag('showMemoryCommitmentChart')
FeatureFlags-->>DatabasePage: showMemoryCommitmentChart flag value
DatabasePage->>ReportBuilder: pass showMemoryCommitmentChart
ReportBuilder->>ChartConfig: check flag & build chart list
alt showMemoryCommitmentChart enabled
ChartConfig->>ChartConfig: include memory-commitment chart<br/>(ram_commit_used, ram_commit_limit)
else showMemoryCommitmentChart disabled
ChartConfig->>ChartConfig: exclude memory-commitment chart
end
ChartConfig-->>ReportBuilder: ReportAttributes[]
ReportBuilder-->>DatabasePage: chart list with conditional chart
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
🎭 Playwright Test ResultsDetails
Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
Adds a Memory commitment section to the database reports guide covering what Committed_AS and CommitLimit are, how to read the four common patterns (flat, gradual rise, spike, sustained over limit), why this matters for Postgres specifically (fork-per-connection, work_mem, OOM killer), and what actions to take. Also points the chart's docsUrl at the new anchor. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The |
Hides the new memory-commitment chart behind a showMemoryCommitmentChart PostHog flag so we can ship the studio change ahead of the platform backend reaching production. Mirrors the existing showDiskIOBurstBalanceChart pattern. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/studio/pages/project/[ref]/observability/database.tsx (1)
140-150:⚠️ Potential issue | 🟠 Major | ⚡ Quick winMissing required telemetry for the new feature-flagged chart.
Line 140 and Lines 149-150 gate behavior behind
showMemoryCommitmentChart, but there is no corresponding telemetry capturing flag state/exposure and user response for this rollout path.As per coding guidelines, “When a feature flag gates new behavior, there should be telemetry on both the flag state and how users respond to the new behavior.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/pages/project/`[ref]/observability/database.tsx around lines 140 - 150, The code gates the new chart behind the feature flag showMemoryCommitmentChart but lacks telemetry for flag exposure and user interactions; add telemetry events when the page/component initializes to record the flag state (e.g., log an event like "feature_exposed" with feature: "showMemoryCommitmentChart" and its boolean value) and when users interact with the new chart (e.g., "feature_used" or chart-specific events). Instrument the initialization path where showMemoryCommitmentChart is read (before or after REPORT_ATTRIBUTES is built) to emit the exposure event, and instrument the chart render/interaction handlers created from getReportAttributesV2/REPORT_ATTRIBUTES to emit usage events so both exposure and response are captured.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/api-types/types/platform.d.ts`:
- Around line 23174-23175: The added union members 'ram_commit_used' and
'ram_commit_limit' in the generated type union were introduced by direct edits
to the auto-generated API types; revert those manual changes and instead update
the OpenAPI spec to include these new enum/union values, then run the
OpenAPI-to-typescript generation step to regenerate
packages/api-types/types/**/*.d.ts so the new members appear from the canonical
source; ensure no direct edits remain in the generated files and commit only the
regenerated artifacts.
---
Outside diff comments:
In `@apps/studio/pages/project/`[ref]/observability/database.tsx:
- Around line 140-150: The code gates the new chart behind the feature flag
showMemoryCommitmentChart but lacks telemetry for flag exposure and user
interactions; add telemetry events when the page/component initializes to record
the flag state (e.g., log an event like "feature_exposed" with feature:
"showMemoryCommitmentChart" and its boolean value) and when users interact with
the new chart (e.g., "feature_used" or chart-specific events). Instrument the
initialization path where showMemoryCommitmentChart is read (before or after
REPORT_ATTRIBUTES is built) to emit the exposure event, and instrument the chart
render/interaction handlers created from getReportAttributesV2/REPORT_ATTRIBUTES
to emit usage events so both exposure and response are captured.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: c45db419-2a0f-4a59-8def-c27aaa751763
📒 Files selected for processing (4)
apps/docs/content/guides/telemetry/reports.mdxapps/studio/data/reports/database-charts.tsapps/studio/pages/project/[ref]/observability/database.tsxpackages/api-types/types/platform.d.ts
|
The |
CodeRabbit flagged that packages/api-types/types/*.d.ts is regenerated from the platform OpenAPI spec and must not be hand-edited. Removing the two manually added attributes; they will reappear naturally on the next regeneration against the merged platform spec. The studio chart keeps working via the existing 'as InfraMonitoringAttribute' cast in ComposedChartHandler. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
fcff967 to
2a01568
Compare
Braintrust eval report
|
Problem
Sustained memory overcommitment is one of the failure patterns that most often leads to databases being killed when the system runs out of memory. Today the database report only shows used memory against total RAM, which hides the kernel's commit accounting: a project can sit far above its commit limit (RAM plus swap, adjusted by the overcommit ratio) and the dashboard gives no signal until something breaks.
A combined chart with swap, overcommitment, and main memory was considered too dense, and a standalone swap chart was not useful enough on its own.
Linear: DEBUG-119
Fix
Adds a separate "Memory commitment" chart between the existing memory usage and swap charts. It plots
ram_commit_used(Committed_AS) as the main series withram_commit_limit(CommitLimit) as the max-value threshold line, so values approaching or crossing the limit are visually obvious. Backend support for the two new metric attributes ships in supabase/platform#33321.How to test
syncId: 'database-reports') keep this chart aligned with the others.Summary by CodeRabbit
Documentation
New Features