mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## What Migrates the `edge-functions-last-hour-stats` query (requests + server error counts shown on the Edge Functions list) from the BigQuery-style `logs.all` endpoint to the OTEL/ClickHouse `logs.all.otel` endpoint. <img width="2378" height="958" alt="CleanShot 2026-07-07 at 16 24 43@2x" src="https://github.com/user-attachments/assets/5bf3f04c-43e1-44a3-af28-d53feee27f68" /> ## How - Adds an OTEL SQL builder that reads from the single `logs` table (`source = 'function_edge_logs'`), using `log_attributes['function_id']` and `toInt32OrZero(log_attributes['response.status_code'])` instead of `cross join unnest(metadata)`. - Gated by the `otelLegacyLogs` flag, matching the rest of the logs code. The BigQuery path is preserved when the flag is off, and the two paths cache under separate query keys. ## Testing - Unit tests cover both endpoints and assert the generated SQL for each path. - Go to edge fns list - stats load correctly <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for using the OTEL logs backend for edge function last-hour stats when enabled. * Queries and caching now automatically distinguish between the standard and OTEL-backed data sources. * **Bug Fixes** * Ensured stats results are fetched from the correct endpoint based on the selected logging backend. * Added coverage to verify OTEL-specific SQL and response behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
24 lines
830 B
TypeScript
24 lines
830 B
TypeScript
export const normalizeFunctionIds = (functionIds: string[]): string[] =>
|
|
Array.from(new Set(functionIds)).sort()
|
|
|
|
export const edgeFunctionsKeys = {
|
|
list: (projectRef: string | undefined) => ['projects', projectRef, 'edge-functions'] as const,
|
|
lastHourStats: (
|
|
projectRef: string | undefined,
|
|
functionIds: string[] = [],
|
|
useOtel: boolean = false
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'edge-functions',
|
|
'last-hour-stats',
|
|
normalizeFunctionIds(functionIds),
|
|
{ otel: useOtel },
|
|
] as const,
|
|
detail: (projectRef: string | undefined, slug: string | undefined) =>
|
|
['projects', projectRef, 'edge-function', slug, 'detail'] as const,
|
|
body: (projectRef: string | undefined, slug: string | undefined) =>
|
|
['projects', projectRef, 'edge-function', slug, 'body'] as const,
|
|
}
|