mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
<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>
105 lines
3.2 KiB
TypeScript
105 lines
3.2 KiB
TypeScript
import { useMemo } from 'react'
|
|
import { ChartMetric } from 'ui-patterns/Chart'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import {
|
|
PageSection,
|
|
PageSectionContent,
|
|
PageSectionMeta,
|
|
PageSectionSummary,
|
|
PageSectionTitle,
|
|
} from 'ui-patterns/PageSection'
|
|
|
|
import { getExecutionTooltipDetails } from './EdgeFunctionMetricTooltipDetails'
|
|
import {
|
|
EXECUTION_TIME_CHART_CONFIG,
|
|
formatMetric,
|
|
getChartEmptyStateCopy,
|
|
} from './EdgeFunctionOverview.utils'
|
|
import { EdgeFunctionTimeSeriesChartCard } from './EdgeFunctionTimeSeriesChartCard'
|
|
import type { EdgeFunctionChartDatum } from './EdgeFunctionOverview.utils'
|
|
|
|
interface EdgeFunctionPerformanceSectionProps {
|
|
data: EdgeFunctionChartDatum[]
|
|
dateTimeFormat: string
|
|
isLoading: boolean
|
|
isError: boolean
|
|
errorMessage?: string
|
|
averageExecutionTime: number
|
|
maxExecutionTime: number
|
|
}
|
|
|
|
export const EdgeFunctionPerformanceSection = ({
|
|
data,
|
|
dateTimeFormat,
|
|
isLoading,
|
|
isError,
|
|
errorMessage,
|
|
averageExecutionTime,
|
|
maxExecutionTime,
|
|
}: EdgeFunctionPerformanceSectionProps) => {
|
|
const emptyStateCopy = getChartEmptyStateCopy('execution time', isError, errorMessage)
|
|
const tooltipDetails = useMemo(
|
|
() => getExecutionTooltipDetails(averageExecutionTime),
|
|
[averageExecutionTime]
|
|
)
|
|
const metrics = (
|
|
<div className="flex flex-wrap gap-x-8 gap-y-4">
|
|
<ChartMetric
|
|
label="Average Execution Time"
|
|
value={formatMetric(averageExecutionTime, 'ms')}
|
|
tooltip="Average execution time of function invocations"
|
|
/>
|
|
<ChartMetric
|
|
label="Max Execution Time"
|
|
value={formatMetric(maxExecutionTime, 'ms')}
|
|
tooltip="Maximum execution time of function invocations"
|
|
/>
|
|
</div>
|
|
)
|
|
|
|
return (
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<PageContainer size="full">
|
|
<div className="flex flex-col gap-6">
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Performance</PageSectionTitle>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
|
|
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
|
<EdgeFunctionTimeSeriesChartCard
|
|
className="lg:col-span-2"
|
|
data={data}
|
|
dateTimeFormat={dateTimeFormat}
|
|
isLoading={isLoading}
|
|
isError={isError}
|
|
emptyTitle={emptyStateCopy.title}
|
|
emptyDescription={emptyStateCopy.description}
|
|
metrics={metrics}
|
|
dataKey="max_execution_time"
|
|
dataKeys={['avg_execution_time', 'max_execution_time']}
|
|
config={EXECUTION_TIME_CHART_CONFIG}
|
|
tooltipDetails={tooltipDetails}
|
|
referenceLines={[
|
|
{
|
|
y: averageExecutionTime,
|
|
label: 'average',
|
|
stroke: 'hsl(var(--foreground-default))',
|
|
strokeWidth: 1.5,
|
|
},
|
|
]}
|
|
yAxisProps={{
|
|
width: 64,
|
|
tickFormatter: (value: number) => `${Math.round(value)}ms`,
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</PageContainer>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)
|
|
}
|