mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
Add tested query support for correlating logs by request and execution IDs across API Gateway, Auth, Storage, and Edge Functions. Queries are source-scoped, time-bounded, and limited to 200 rows, with at most one additional lookup to follow a newly discovered execution ID. This data-only layer introduces no UI or automatic requests. The Timeline tab consumes its query options in #50836. Overview and request correlation share a cached source-and-attributes lookup, including concurrent requests. Cancelling a timeline preserves any shared overview lookup. The new query is exercised through MSW without mocking React Query hooks. ### How to test This is a data-only PR. From the repository root, run: ```sh pnpm --filter studio exec vitest run components/interfaces/UnifiedLogs/UnifiedLogs.queries.test.ts data/logs/unified-log-request-timeline-query.test.ts ``` The tests exercise source-scoped IDs, SQL escaping, time/row limits, missing IDs, failed requests, the additional execution-ID lookup, attribute-cache reuse in both navigation orders and concurrently, and cancellation through MSW. ### Validation - Synced with master; verified head `a60bcf0565e0e3477779665660e871eec2edd2c8`. - Focused unit/MSW baseline and shuffled seed 5084028: 121 tests across seven files passed with retries disabled. Independent shuffled run, seed 5084029: 117 tests across six files passed. - Correlation, shared lookup/cache, cancellation, and the 400-second function boundary are covered. Behavioral mutation checks detect shared-lookup cancellation and a shortened execution window. - Matching studio-staging preview smoke check passed for existing grouped overview attributes and complete copied Raw JSON metadata. - All four unit-test shards, all four E2E shards, typecheck, formatting, lint ratchet, knip, and Studio Docker build passed on this head. - Independent review found no actionable issues; no unresolved review threads. ### Stack Based on the logs table building blocks stack, which merges first: #50953 → #50954 → #50955 → #50957 → #50958 → #52281. Then merge in order: 1. #50835 — grouped log overviews and raw JSON 2. #50840 — request correlation queries 3. #50836 — request timeline UI and folding 4. #50841 — shared Auth user details 5. #50837 — log user correlation and Auth activity --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Jordi Enric <jordi.err@gmail.com>
101 lines
2.6 KiB
TypeScript
101 lines
2.6 KiB
TypeScript
import { QuerySearchParamsType } from '@/components/interfaces/UnifiedLogs/UnifiedLogs.types'
|
|
|
|
export const logsKeys = {
|
|
otelLogKeys: (projectRef: string | undefined, source: string | undefined) =>
|
|
['projects', projectRef, 'otel-log-keys', source] as const,
|
|
unifiedLogsInfinite: (
|
|
projectRef: string | undefined,
|
|
searchParams: QuerySearchParamsType | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'logs-data',
|
|
...(searchParams ? [searchParams].filter(Boolean) : []),
|
|
] as const,
|
|
unifiedLog: (
|
|
projectRef: string | undefined,
|
|
searchParams: QuerySearchParamsType,
|
|
id: string | undefined
|
|
) => ['projects', projectRef, 'unified-logs', 'single-log', searchParams, id] as const,
|
|
unifiedLogsCount: (
|
|
projectRef: string | undefined,
|
|
searchParams: QuerySearchParamsType | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'count-data',
|
|
...(searchParams ? [searchParams].filter(Boolean) : []),
|
|
] as const,
|
|
unifiedLogsChart: (
|
|
projectRef: string | undefined,
|
|
searchParams: QuerySearchParamsType | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'chart-data',
|
|
...(searchParams ? [searchParams].filter(Boolean) : []),
|
|
] as const,
|
|
unifiedLogsFacetCount: (
|
|
projectRef: string | undefined,
|
|
facet: string,
|
|
facetSearch: string | undefined,
|
|
searchParams: QuerySearchParamsType | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'count-data',
|
|
facet,
|
|
facetSearch,
|
|
...(searchParams ? [searchParams].filter(Boolean) : []),
|
|
] as const,
|
|
logAttributes: (
|
|
projectRef: string | undefined,
|
|
logId: string | undefined,
|
|
source: string | undefined,
|
|
logTimestampMs: number | null | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'log-attributes',
|
|
logId,
|
|
{ source, logTimestampMs },
|
|
] as const,
|
|
requestTimeline: (
|
|
projectRef: string | undefined,
|
|
logId: string | undefined,
|
|
source: string | undefined,
|
|
logTimestampMs: number | null | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'request-timeline',
|
|
logId,
|
|
{ source, logTimestampMs },
|
|
] as const,
|
|
serviceFlow: (
|
|
projectRef: string | undefined,
|
|
searchParams: QuerySearchParamsType | undefined,
|
|
logId: string | undefined
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'unified-logs',
|
|
'service-flow',
|
|
logId,
|
|
...(searchParams ? [searchParams].filter(Boolean) : []),
|
|
] as const,
|
|
}
|