mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem The Warehouse integration overview shows replication status but gives no view of query activity. ## Solution Add last-hour query rate and p95 duration charts, with refresh and a link to Observability. Metrics failures appear beside the replication information. | Before | After | | --- | --- | | <img width="1292" height="1288" alt="CleanShot 2026-11-18 at 13 44 48@2x" src="https://github.com/user-attachments/assets/f06314bb-8322-448b-a86b-6821a3427a52" /> | <img width="1314" height="1930" alt="CleanShot 2026-11-18 at 13 45 10@2x" src="https://github.com/user-attachments/assets/0cbaab85-b7bb-445d-8547-3c772010a0d1" /> | | _No “Workload” section._ | _A new “Workload” section._ | Depends on #53574. ## Review instructions 1. Open the [Studio staging preview](https://studio-staging-git-dnywh-warehouse-overview-workload-supabase.vercel.app) with a staging project that has Warehouse configured. 2. Go to **Integrations > Warehouse > Overview**. Check the **Workload** charts below replication status. 3. Refresh the charts, then use **Observability** to open the full report. 4. Check a period without query activity. The empty message should name the last 60 minutes. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import type { UseQueryResult } from '@tanstack/react-query'
|
|
|
|
import type {
|
|
WarehouseMetricsData,
|
|
WarehouseMetricsError,
|
|
} from '@/data/warehouse/warehouse-metrics-query'
|
|
|
|
export type WorkloadView =
|
|
| { kind: 'loading' }
|
|
| { kind: 'error'; error: WarehouseMetricsError }
|
|
| { kind: 'unavailable'; isRefreshing: boolean }
|
|
| { kind: 'ready'; data: WarehouseMetricsData; isRefreshing: boolean }
|
|
|
|
export function getWorkloadView(
|
|
query: UseQueryResult<WarehouseMetricsData, WarehouseMetricsError>
|
|
): WorkloadView {
|
|
if (query.isPending) return { kind: 'loading' }
|
|
if (query.isError) return { kind: 'error', error: query.error }
|
|
|
|
const isUnavailable =
|
|
query.data.metrics.length > 0 &&
|
|
query.data.metrics.every((metric) =>
|
|
['disabled', 'not_provisioned'].includes(metric.availability)
|
|
)
|
|
|
|
if (isUnavailable) return { kind: 'unavailable', isRefreshing: query.isFetching }
|
|
|
|
return { kind: 'ready', data: query.data, isRefreshing: query.isFetching }
|
|
}
|
|
|
|
export function getWorkloadStatus(view: WorkloadView) {
|
|
switch (view.kind) {
|
|
case 'loading':
|
|
return 'Loading workload metrics'
|
|
case 'error':
|
|
return 'Failed to load workload metrics'
|
|
case 'unavailable':
|
|
return view.isRefreshing ? 'Loading workload metrics' : 'Warehouse metrics are unavailable'
|
|
case 'ready':
|
|
return view.isRefreshing ? 'Loading workload metrics' : 'Workload metrics loaded'
|
|
}
|
|
}
|