Files
supabase/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionTimeSeriesChartCard.tsx
Saxon Fletcher e21088144d Edge function overview (#44009)
<img width="1575" height="1134" alt="image"
src="https://github.com/user-attachments/assets/994b1113-717f-44a2-89a4-13bc0182db20"
/>

Attempts to improve our edge function overview pages to provide stronger
insights into the health of a function, including reliability (error
rates), performance (execution times) and usage (cpu and memory).

As part of this work it refactors existing charts to use our new chart
components.

main consideration is the collective performance of error queries
https://github.com/supabase/supabase/pull/44009/changes#diff-2a79cf61c5397a8ef363c333229fa7729a2efc90a4d8e0806e49c212d5aa97e7

## To test:
1. Create an edge function that errors out randomly across requests. You
can use cron to poll this function every second.
2. View the edge function and on the overview page confirm that errors
are showing and grouped correctly in recent failed invocations sections.

---------

Co-authored-by: Ali Waseem <waseema393@gmail.com>
2026-04-01 14:59:12 +10:00

79 lines
2.0 KiB
TypeScript

import type { ReactNode } from 'react'
import type { ChartConfig } from 'ui'
import {
Chart,
ChartCard,
ChartContent,
ChartHeader,
ChartLine,
ChartLoadingState,
type ChartLineProps,
} from 'ui-patterns/Chart'
import { EdgeFunctionChartEmptyState } from './EdgeFunctionChartEmptyState'
import type { EdgeFunctionChartDatum } from './EdgeFunctionOverview.utils'
interface EdgeFunctionTimeSeriesChartCardProps {
data: EdgeFunctionChartDatum[]
dateTimeFormat: string
isLoading: boolean
isError: boolean
emptyTitle: string
emptyDescription?: string
metrics: ReactNode
dataKey: string
dataKeys?: string[]
config: ChartConfig
tooltipDetails?: ChartLineProps['tooltipDetails']
referenceLines?: ChartLineProps['referenceLines']
yAxisProps?: ChartLineProps['YAxisProps']
className?: string
}
export const EdgeFunctionTimeSeriesChartCard = ({
data,
dateTimeFormat,
isLoading,
isError,
emptyTitle,
emptyDescription,
metrics,
dataKey,
dataKeys,
config,
tooltipDetails,
referenceLines,
yAxisProps,
className,
}: EdgeFunctionTimeSeriesChartCardProps) => {
return (
<Chart isLoading={isLoading} className={className}>
<ChartCard>
<ChartHeader align="start">{metrics}</ChartHeader>
<ChartContent
isEmpty={isError || data.length === 0}
emptyState={
<EdgeFunctionChartEmptyState title={emptyTitle} description={emptyDescription} />
}
loadingState={<ChartLoadingState />}
>
<div className="h-40">
<ChartLine
data={data}
dataKey={dataKey}
dataKeys={dataKeys}
DateTimeFormat={dateTimeFormat}
isFullHeight
showYAxis
config={config}
tooltipDetails={tooltipDetails}
referenceLines={referenceLines}
YAxisProps={yAxisProps}
/>
</div>
</ChartContent>
</ChartCard>
</Chart>
)
}