The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add a custom log detail fetcher + logs overview for supavisor (#52142)
Joshen Lim9048d86e3557
diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/LogOverview.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/LogOverview.tsxindex 93f29fe7c83..9397aef19c3 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/LogOverview.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/LogOverview.tsx@@ -12,6 +12,7 @@ import {MemoizedPostgresBlock,MemoizedPostgRESTBlock,MemoizedStorageBlock,+ MemoizedSupavisorBlock,} from './components/ServiceBlocks'import type { ServiceFlowBlockProps } from './types'import { DetailSectionHeader } from '@/components/ui/DataTable/DetailSectionHeader'@@ -37,6 +38,21 @@ function RequestOverview({ children, ...props }: LogOverviewProps & { children:)}+function SupavisorOverview(props: LogOverviewProps) {+ const timestamp = getRowTimestampMs(props.data)+ return (+ <>+ <DetailSectionHeader+ title="Event time"+ className="border-b"+ icon={ClockIcon}+ summary={timestamp === null ? undefined : new Date(timestamp).toLocaleString()}+ />+ <MemoizedSupavisorBlock {...props} />+ </>+ )+}+function PostgrestOverview(props: LogOverviewProps) {return (<RequestOverview {...props}>@@ -79,6 +95,7 @@ const LOG_OVERVIEW_RENDERERS: Partial<auth: AuthOverview,storage: StorageOverview,'edge function': EdgeFunctionOverview,+ supavisor: SupavisorOverview,}export function LogOverview(props: LogOverviewProps) {diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceBlocks.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceBlocks.tsxindex e2bbe6b4a08..69639b44495 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceBlocks.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceBlocks.tsx@@ -5,6 +5,7 @@ import {postgresBlockConfig,postgrestBlockConfig,storageBlockConfig,+ supavisorBlockConfig,} from '../config/blockConfigs'import { createBlock } from './shared/Block'@@ -26,3 +27,6 @@ MemoizedStorageBlock.displayName = 'MemoizedStorageBlock'export const MemoizedPostgresBlock = createBlock(postgresBlockConfig)MemoizedPostgresBlock.displayName = 'MemoizedPostgresBlock'++export const MemoizedSupavisorBlock = createBlock(supavisorBlockConfig)+MemoizedSupavisorBlock.displayName = 'MemoizedSupavisorBlock'diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsxindex ff26d1f8bdd..c336bc02f74 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsx@@ -43,7 +43,6 @@ export const DetailRow = ({table={table}disabled={isLoading}truncateLabel={!wrap}- alignOffset={38}// Indent past the section header iconclassName="pl-[38px]">@@ -65,7 +64,11 @@ interface FieldValueProps {const FieldValue = ({ config, value, wrap, level }: FieldValueProps): ReactNode => {if (value === null || value === undefined || value === '') {- return <span className="font-mono text-sm leading-5 text-foreground-muted">—</span>+ return (+ <code data-code-style="plain" className="text-foreground-muted">+ -+ </code>+ )}if (config.id === 'status') {@@ -80,14 +83,12 @@ const FieldValue = ({ config, value, wrap, level }: FieldValueProps): ReactNodeif (typeof value === 'string' || typeof value === 'number') {return (- <span- className={cn(- 'font-mono text-sm leading-5 text-foreground min-w-0',- wrap ? 'break-all text-right' : 'truncate text-right'- )}+ <code+ data-code-style="plain"+ className={cn('text-xs', wrap ? 'break-all text-right' : 'truncate text-right')}>{value}- </span>+ </code>)}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.ts b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.tsindex 5947a4a0ace..92bbacda0e5 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.ts@@ -29,6 +29,9 @@ import {postgrestResponseFields,storageDetailsFields,storagePrimaryFields,+ supavisorNodeFields,+ supavisorPrimaryFields,+ supavisorSourceFields,techDetailsFields,userAdditionalFields,userPrimaryField,@@ -124,3 +127,21 @@ export const postgresBlockConfig: BlockConfig = {},],}++export const supavisorBlockConfig: BlockConfig = {+ title: 'Supavisor',+ icon: CableIcon,+ primaryFields: supavisorPrimaryFields,+ sections: [+ {+ title: 'Node Details',+ icon: ServerIcon,+ fields: supavisorNodeFields,+ },+ {+ title: 'Source',+ icon: CodeIcon,+ fields: supavisorSourceFields,+ },+ ],+}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.tsindex da5b474fdee..f759d9a88fd 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts@@ -765,3 +765,52 @@ export const postgresDetailsFields: BlockFieldConfig[] = [requiresEnrichedData: true,},]++// =============================================================================+// SUPAVISOR FIELDS+// =============================================================================++// Supavisor rows carry everything under `metadata` (the OTEL `log_attributes` map).+const supavisorField = (+ key: string,+ label: string,+ options?: Pick<BlockFieldConfig, 'wrap'>+): BlockFieldConfig => ({+ id: key,+ label,+ getValue: (_data, enrichedData) => enrichedData?.metadata?.[key],+ requiresEnrichedData: true,+ ...options,+})++export const supavisorPrimaryFields: BlockFieldConfig[] = [+ {+ id: 'event_message',+ label: 'Message',+ getValue: (data, enrichedData) => enrichedData?.event_message || data?.event_message,+ wrap: true,+ },+ supavisorField('user', 'User'),+ supavisorField('db_name', 'Database'),+ supavisorField('mode', 'Pool mode'),+ supavisorField('type', 'Pool type'),+ supavisorField('state', 'State'),+ supavisorField('app_name', 'Application'),+ supavisorField('peer_ip', 'Peer IP'),+ supavisorField('local', 'Local'),+]++export const supavisorNodeFields: BlockFieldConfig[] = [+ supavisorField('region', 'Region'),+ supavisorField('location', 'Location'),+ supavisorField('nodehost', 'Node host', { wrap: true }),+ supavisorField('instance_id', 'Instance ID'),+]++export const supavisorSourceFields: BlockFieldConfig[] = [+ supavisorField('context.module', 'Module', { wrap: true }),+ supavisorField('context.function', 'Function'),+ supavisorField('context.file', 'File', { wrap: true }),+ supavisorField('context.line', 'Line'),+ supavisorField('context.pid', 'Process ID'),+]diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsxindex eeca5afd89c..b6633cfdc0a 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsx@@ -103,7 +103,7 @@ export function ServiceFlowPanel({<TabsTrigger value="raw-json">Raw JSON</TabsTrigger><TabsIndicator /></TabsList>- {['overview', 'raw-json'].map((tab) => (+ {(['overview', 'raw-json'] as const).map((tab) => (<TabsContentkey={`${tab}-${selectedRow?.id}`}value={tab}diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogDetail.tsx b/apps/studio/components/interfaces/UnifiedLogs/components/LogDetail.tsxindex 12d6ec1b548..7841602914f 100644--- a/apps/studio/components/interfaces/UnifiedLogs/components/LogDetail.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogDetail.tsx@@ -22,7 +22,7 @@ export function LogDetail({searchParameters,}: {row: ColumnSchema- tab: string+ tab: 'overview' | 'raw-json'searchParameters: QuerySearchParamsType}) {const { ref: projectRef } = useParams()diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsx b/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsxindex 79284e02377..923f4fb28da 100644--- a/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsx@@ -18,7 +18,6 @@ interface LogFieldRowProps<TData> {disabled?: boolean/** Truncate the label to one line instead of wrapping it. */truncateLabel?: boolean- alignOffset?: numberclassName?: string}@@ -32,7 +31,6 @@ export function LogFieldRow<TData>({table,disabled,truncateLabel = false,- alignOffset = 16,className,}: LogFieldRowProps<TData>) {return (@@ -44,7 +42,6 @@ export function LogFieldRow<TData>({label={label}disabled={disabled}className="rounded-none"- alignOffset={alignOffset}><divrole="button"diff --git a/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx b/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsxindex 96859a947c3..0b7871bf397 100644--- a/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx+++ b/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx@@ -37,7 +37,6 @@ interface DataTableSheetRowActionProps<value: string | numbertable?: Table<TData>label?: string- alignOffset?: number}export function DataTableSheetRowAction<TData, TFields extends DataTableFilterField<TData>>({@@ -48,7 +47,6 @@ export function DataTableSheetRowAction<TData, TFields extends DataTableFilterFiclassName,table,label,- alignOffset = 8,onKeyDown,...props}: DataTableSheetRowActionProps<TData, TFields>) {@@ -201,7 +199,7 @@ export function DataTableSheetRowAction<TData, TFields extends DataTableFilterFi{children}</DropdownMenuTrigger>- <DropdownMenuContent align="start" alignOffset={alignOffset} side="bottom" className="w-56">+ <DropdownMenuContent align="end" alignOffset={12} side="bottom" className="w-56">{!!field && !!column && (<>{renderOptions()}diff --git a/apps/studio/data/logs/unified-log-inspection-query.ts b/apps/studio/data/logs/unified-log-inspection-query.tsindex 43894fbe7d1..a6b0ee9723d 100644--- a/apps/studio/data/logs/unified-log-inspection-query.ts+++ b/apps/studio/data/logs/unified-log-inspection-query.ts@@ -31,6 +31,7 @@ export const SERVICE_FLOW_TYPES = ['edge-function','storage','postgres',+ 'supavisor',] as constexport type ServiceFlowType = (typeof SERVICE_FLOW_TYPES)[number]@@ -47,6 +48,7 @@ const SERVICE_FLOW_TYPE_SOURCE: Record<ServiceFlowType, SafeLogSqlFragment> = {'edge-function': lit(LOG_TYPE_TO_SOURCE['edge function']),storage: lit(LOG_TYPE_TO_SOURCE.storage),postgres: lit(LOG_TYPE_TO_SOURCE.postgres),+ supavisor: lit(LOG_TYPE_TO_SOURCE.supavisor),}export type UnifiedLogInspectionVariables = {@@ -254,6 +256,21 @@ LIMIT 1return { result: [] }}+ // Supavisor rows aren't HTTP requests, so skip the flattened HTTP-shaped entry and+ // return the raw attributes as `metadata` for the supavisor block and Raw JSON tab.+ if (type === 'supavisor') {+ return {+ result: [+ {+ id: row.id,+ timestamp: row.timestamp,+ event_message: row.event_message,+ metadata: row.log_attributes ?? {},+ },+ ],+ }+ }+const entry = flattenOtelInspectionRow(row) as UnifiedLogInspectionEntry & Record<string, unknown>// For edge function rows, fetch and aggregate the related `function_logs`