mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
create-pull-request/patch
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1ef66de793 |
feat(studio): add trace span route query (#54391)
## Problem
The Unified Logs trace tab needs the spans for a request's trace.
Nothing in Studio fetches them yet.
Part 2 of 3. Data layer only — the tab that consumes this lands in part
3.
## Solution
Adds `unifiedLogTraceSpansQueryOptions`, fetching `GET
/v2/projects/{ref}/analytics/traces/{trace_id}`, plus the `traceSpans`
query key.
Two choices worth flagging:
**Fetched and parsed directly, not through the typed client.** The route
is live in the v2 OpenAPI spec, but it isn't in the committed
`api-types` — and `get()` is typed off the generated `paths`, so it
can't address a route that isn't there. Getting it there means
regenerating `api-types`, which currently drags in a large amount of
unrelated production drift and breaks Studio's typecheck in three
places. That's worth doing on its own, not as a side effect of this. So
the query goes through `fetchHandler` and parses the response with zod,
following the `platform-apps/platform-app-query.ts` precedent.
The parse likely stays even after a regen: the spec declares no
`additionalProperties` on a span's `attributes`, so the generated type
would describe only the seven known keys and none of the OTel attributes
the trace view actually reads (`http.route`, `url.full`, `db.*`, and
whatever else a service reports). `.passthrough()` keeps them. It also
means the parse is load-bearing — it's the only thing validating the
response shape at runtime, so a backend change surfaces as an error at
the boundary rather than a build failure.
**A temporary knip entry.** Nothing imports the query until part 3, so
knip reports it as an unused file and fails the build. Per
`apps/studio/AGENTS.md`, it's listed in `knip.jsonc` with a `used from
#NNN` comment; part 3 deletes that entry when it adds the importer.
## Review instructions
1. Check the zod schema against the live spec — it should match field
for field:
```bash
curl -s https://api.supabase.com/api/v2-json \
| jq '.components.schemas.ListSpansResponse_Output'
```
2. Confirm the knip entry in `knip.jsonc` is marked temporary and points
at part 3.
3. Run `pnpm knip --workspace apps/studio` and confirm it passes.
## Checklist
Check all before review:
- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
|
||
|
|
6612073428 |
feat(studio): add bounded request correlation queries (#50840)
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> |
||
|
|
671594c69c |
feat(studio): group log overviews and standardize raw JSON (#50835)
Logs without a service-specific overview now show common fields and attributes in collapsible groups. Existing service overviews use the same section layout, with the first section open. Configured fields share one renderer across service overviews. Raw JSON uses shared presentation for single-log, multi-log, and downstream Auth views, with copy controls supplied by each view. Attribute lookups are scoped to the selected log's source, ID, and timestamp window and respect metadata visibility. It's based on the #50953 stack; request correlation, timeline UI, and Auth changes are separate layers. Sections use the `CollapsibleDetailSection` that master now shares with the audit log pages, and the new Supavisor overview follows the same layout: no separate time header, first section open. ### How to test 1. With Unified Logs and `otelUnifiedLogs` enabled, open an API Gateway log and a Postgres or Auth log. Check the overview sections, expand/collapse groups, and try copying a field. 2. Open Raw JSON on a log with enough metadata to scroll. Confirm the copy button stays visible and copies the complete JSON. 3. Select multiple logs and confirm their combined JSON still renders correctly. ### Validation - Synced with master; verified head `663ebfd13117ae3c5aa0de52e4488253a317d59f`. - Focused local unit/MSW suite: 246 tests passed across 19 files with retries disabled, both normally and with `--sequence.shuffle --sequence.seed=50835`. Independent focused run: 24 tests passed with seed 5083528. - Browser QA on the matching studio-staging preview passed: API Gateway and Postgres section expansion/collapse, field copying, scrolling and copying complete Raw JSON, and copying multiple selected logs. - All four unit-test shards, all four E2E shards, typecheck, formatting, lint ratchet, and Studio Docker build passed. The Next.js E2E report includes one storage-folder test that passed on retry. - Independent code review found no actionable issues. Working tree clean. ### 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> |
||
|
|
5d52b00f70 |
feat(studio): combine function invocations and logs (#50957)
With the unified logs preview on, an edge function's Logs tab renders the unified logs view scoped to that function (#50954), with its invocations and runtime output in one list. That replaces the separate Invocations and Logs tabs. - `UnifiedLogs` takes a `scope` plus view props: `hasFilterSideBar`, `offeredFilters` and `columnPreferencesKey`. The function Logs tab turns the sidebar off, which also drops the filters-toggle shortcut, and saves its columns and panel layout separately from the Logs page. - `getEdgeFunctionLogsScope` and `EDGE_FUNCTION_LOGS_VIEW` are the edge function preset: the scope's fixed filters, the filters the tab offers and its saved-columns key. It offers date, log type, level and message, so no user filter, since no function row has a user. - The Invocations tab and its shortcut are hidden. Old Invocations links redirect to Logs, converting `its`/`ite`/`log` to `date`/`id`. - `getEdgeFunctionLogsUrl` builds links into the scoped tab with the shared params serializer from #50953, and clicking a bar on the invocations chart uses it. With the preview off, both tabs work as on master. ### How to test 1. Turn on the unified logs preview and open an edge function's Logs tab. You should see only that function's invocations and runtime logs, with the filter bar limited to date, log type, level and message. 2. Filter to Edge Function runtime, then to errors, and check counts and the chart follow. 3. Open an old `/functions/<slug>/invocations?its=…&ite=…&log=…` link. It lands on Logs with the same range and log selected. 4. Click a bar on the Overview invocations chart. The Logs tab opens on that bucket. ### Validation - URL helper, offered filter and preset tests, plus the scoped query tests from #50954. - Studio typecheck, lint ratchet, Prettier and knip pass on this layer. ### Stack Merge in order: 1. #50953 — reusable logs table building blocks 2. #50954 — function-scoped unified logs queries 3. #50955 — slimmer function detail layout, header on Overview 4. #50957 — Invocations merged into a function-scoped Logs tab 5. #50958 — Overview errors in the shared logs table 6. #52281 — remove the legacy Overview --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Jordi Enric <jordi.err@gmail.com> |
||
|
|
8b38e0d1ed |
feat(studio): ClickHouse dialect for logs snippet AI + rewrite to ClickHouse (#48501)
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Feature, plus a refactor of the shared logs-rewrite flow. PR 8 of the SQL editor query-source series. Stacked on #48457 — review that one first, and merge this after it. ## What is the current behavior? A `log_sql` snippet runs against the ClickHouse-backed analytics endpoint, but the SQL editor's AI still writes Postgres: inline edits get Postgres system prompts, and the result is run through `sql-formatter`, which mangles ClickHouse backticks and `log_attributes` map lookups. Legacy Logs Explorer saved queries open in the editor as `log_sql` snippets. Those are BigQuery dialect and error against the ClickHouse endpoint the editor runs them on, with no in-editor way out — only the Logs Explorer offered a rewrite. The completion route was also asymmetric. It assembled a schema/code/instruction message for Postgres but forwarded `prompt` verbatim for ClickHouse, so a client wanting ClickHouse had to hand-build the equivalent string. ## What is the new behavior? **Inline AI speaks ClickHouse for logs snippets.** `sqlSourceToDialect` maps a snippet's source to `postgres`/`clickhouse` and `buildCompletionRequestBody` threads it through. For ClickHouse, `useSqlEditorAi` strips code fences from the response and skips `formatSql`. Execution and dialect both follow the snippet type, so a snippet's valid dialect never flips. **Rewrite to ClickHouse in the editor.** A banner offers the rewrite for a logs snippet whose text trips `looksLikeLegacyLogsQuery`, and proposes the result through the editor's existing AI diff view rather than replacing the snippet, so it's accepted or discarded like any other AI edit. Gated on `otelLegacyLogs`: on a non-migrated org the BigQuery text is still correct, so rewriting it would break a working query. The offer is a state machine (`offered` / `rewriting` / `failed` / `noRewriteNeeded` / `dismissed`) with a declarative table of valid transitions, so the states are mutually exclusive by construction and dismissal is terminal. A failure keeps its message and offers a retry; a response identical to the input is reported rather than opening an empty diff. **One place assembles completion prompts.** The route now uses a single template for both dialects, branching only the schema section and — for `intent: 'rewrite'` — the instruction. `lib/ai/clickhouse-logs.ts` is the single home for ClickHouse-logs prompt content, replacing two independently maintained descriptions of the same table. Clients carry no prompt text. **The rewrite flow is shared with the Logs Explorer.** Both surfaces previously hand-rolled the same sequence and had drifted: only one detected a no-op rewrite, they sourced `log_attributes` keys differently, and the Explorer formatted errors with an `as Error` cast. Both now use `useLegacyLogsRewrite` and the same state-driven banner, so the Explorer picks up no-op detection and typed error extraction. **Attribute keys are fetched on submit, not while typing.** The detected source would otherwise feed a reactive query key, making every edit that changed it cost another network call. `useLogsAttributeKeys` is imperative and goes through `queryClient.fetchQuery`, so a source already cached — including by the Explorer header and query panel, which subscribe reactively — is reused. This also closes a gap where inline edits never received keys at all, unlike full rewrites. `getErrorMessage` gains an optional typed fallback and no longer stringifies a bare object into `'[object Object]'`; every existing caller already hand-rolled a fallback, except `QueueSettings`, which interpolated the raw result and now passes one. Nothing here is user-visible until the `sqlEditorLogsSource` flag is enabled. Tests: dialect selection and request-body shape, the ClickHouse prompt content (including that the schema section does not restate the dialect rules), the reducer's valid and invalid transitions, `shouldOfferLegacyLogsRewrite`, on-submit key discovery with cache reuse, and `getErrorMessage`. ## Additional context <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added an Assistant banner to help rewrite legacy BigQuery-style logs queries into ClickHouse SQL. * SQL assistance now adapts to the selected query type, including relevant log attribute context. * Rewrite suggestions can be reviewed as editor diffs before being applied. * **Bug Fixes** * Improved rewrite failure handling, retry options, dismissal behavior, and “no rewrite needed” messaging. * Error notifications now provide a clearer fallback message when details are unavailable. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
3b7052b5a9 | cleanup: fix import order and prefixes for studio/data (#44501) | ||
|
|
22f937c954 |
Chore/async filters for unified logs (#37200)
* Refactor retrieval of log counts * Async filters * Clean up * Clean up * Fix |
||
|
|
1e3b5063bb |
Feat/unified logs inspection panel (#36895)
* Update QueryOptions.ts * Create UnifiedLogs_InspectionPanel_Architecture.md * init new queries * Create UnifiedLogs_ServiceFlow_Implementation_Plan.md * Add service flow blocks to UnifiedLogs panel Introduces ServiceFlowBlocks components to visually represent the service flow in UnifiedLogs, including Origin, Network, PostgREST, Postgres, and Response steps. Adds utility formatters and updates ServiceFlowPanel to render the new blocks with enriched data and loading/error states. * Enable filterable fields in ServiceFlow blocks Refactored ServiceFlow blocks to support filterable fields by passing filterFields and table props, updating BlockField to render filterable values as clickable actions, and aligning field configs with filterable IDs. Updated ServiceFlowPanel to use new block names and pass required props. This enhances interactivity and consistency in the UnifiedLogs service flow UI. * Update ServiceFlowBlocks.tsx * Enhance Service Flow with enriched fields and filtering Expanded the Service Flow SQL query to extract 35+ flattened, meaningful fields including request, response, client location, network, headers, and JWT data. Updated the implementation plan to reflect new block architecture, filtering integration, and future enhancements. Added debug logging for enriched and raw log data in ServiceFlowPanel. * Start adding inspection panel * Moar logs * Add Postgres service flow support to Unified Logs Introduces Postgres as a first-class service flow type in Unified Logs, including SQL query, type definitions, UI blocks, and filtering. Updates ServiceFlow queries, types, and UI components to display enriched Postgres log details and event messages. Also refines filter fields, log type ordering, and minor UI adjustments for clarity and consistency. * Lots of tidying up, moving blocks into their own files. * Remove UnifiedLogs architecture and service flow docs Deleted documentation files related to UnifiedLogs inspection panel architecture, service flow field mapping, implementation plan, and integration example. This cleans up outdated or redundant design and implementation reference materials. * Refactor service flow blocks to use unified config system Replaces individual service block components with a generic, config-driven system. Introduces a shared Block component and centralizes block configuration in blockConfigs.ts, reducing duplication and improving maintainability. Updates imports and removes now-unnecessary block files. Also refactors ServiceFlowPanel to use the new block structure and simplifies layer icon logic. * Refactor ServiceFlow blocks and utilities structure Consolidates edge service flow SQL queries to reduce duplication, removes ServiceFlowBlocks.tsx in favor of more modular block/component structure, and moves storage-specific utilities to a new utils/storageUtils.ts file. Updates imports in config files and ServiceFlowPanel to reflect the new structure. Type definitions are clarified and extended in types.ts. * Update ServiceFlow.sql.ts * Refactor ServiceFlow types for stronger type safety Replaces generic 'any' types with specific types such as ColumnSchema, QuerySearchParamsType, and SearchParamsType in ServiceFlow components and ServiceFlowPanel. This improves type safety and code clarity, and removes unused metadata and workaround variables from ServiceFlowPanel. * Remove debug flags and console logs from ServiceFlow components Eliminated unused DEBUG_SERVICE_FLOW flags and related console logging from ServiceFlow.sql.ts and ServiceFlowPanel.tsx to clean up the codebase and reduce unnecessary output. * Remove unused log query and filtering functions Deleted unused functions related to log level filtering, base condition building, and the edge/supavisor logs queries. This cleanup simplifies the UnifiedLogs.queries.ts file by removing legacy or currently unused code. * revert * Remove ServiceFlow panel and types, update DataTableToolbar Deleted the ServiceFlowPanel component and its associated types from the UnifiedLogs interface. Updated DataTableToolbar to toggle between PanelLeftClose and PanelLeftOpen icons based on the open state. * Remove unused totalRows prop from DataTable Eliminates the totalRows prop from UnifiedLogs and its context interface, as it is no longer used. This helps clean up the component API and related type definitions. * Refactor log field configs and unify event message component Replaces specialized PostgresEventMessage with a generic EventMessage component and updates references accordingly. Consolidates all log field configuration files into serviceFlowFields.ts, removing separate config files for each service. Cleans up unused types and utility imports, and deletes redundant formatters. * Show empty state for Postgres block with no data Added logic to display an empty state in the Postgres block when no Postgres data is available in non-Postgres logs. Also updated ServiceFlowPanel to render both PostgREST and Postgres blocks, ensuring the empty state is shown when appropriate. * Remove Log Details tab from ServiceFlowPanel The Log Details tab and its associated content have been removed from the ServiceFlowPanel component. This simplifies the UI by focusing on the Overview and Raw JSON tabs. * Update UnifiedLogs.queries.ts * Update UnifiedLogs.queries.ts * Update apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/BlockField.tsx * Refactor UnifiedLogs layout and improve service type formatting Refactored UnifiedLogs.tsx to use a more flexible ResizablePanelGroup layout, replaced inline function logs panel with a new LogsListPanel component, and removed unused imports and code. Updated ServiceFlow.sql.ts to simplify JWT payload extraction and added a dedicated query for edge function service flow. Added a utility to format service type strings for display in UnifiedLogs.utils.ts. * Refactor logs UI and improve service flow handling Renamed FunctionLogsTab to LogsList and added a new LogsListPanel for displaying function logs in a side panel. Improved ServiceFlowPanel with better panel sizing, conditional query enabling, and UI adjustments. Enhanced EventMessage with badge styling and service type formatting. Updated CollapsibleSection for cleaner layout. Enabled debug mode in unified-log-inspection-query. Updated FilterSideBar to use ResizablePanel for improved layout flexibility. * Refactor UnifiedLogs UI and ServiceFlow query fields Removes unused skeletonClassName from BlockFieldConfig and related UI, simplifies ServiceFlow SQL query by returning null for unused JWT fields, and updates UnifiedLogs and LogsListPanel for improved layout and collapsible logs panel. Also adjusts table and log list row heights for better visual consistency. * Update ServiceFlowHeader.tsx * Update ServiceFlowHeader.tsx * Refactor ServiceFlowPanel and header tooltip logic Replaces custom tooltip implementation in ServiceFlowHeader with ButtonTooltip for navigation buttons. Simplifies serviceFlowType logic in ServiceFlowPanel by removing the getServiceFlowType helper and using direct mapping, reducing code complexity. * Update UnifiedLogs.constants.tsx * Remove commented code and add doc comment in UnifiedLogs Removed an unused commented-out span in UnifiedLogs.fields.tsx and added a documentation comment for the Supabase storage logs query fragment in UnifiedLogs.queries.ts. * Update UnifiedLogs.tsx * Remove 'live' level from DataTable components Eliminated the 'live' level from LEVELS constant and related color utility logic. Also removed commented code and references to 'live' in DataTableFilterControls and LiveRow, streamlining the DataTable component's status handling. * Update UnifiedLogs.constants.tsx * cleanup --------- Co-authored-by: Alaister Young <a@alaisteryoung.com> |
||
|
|
2808931f92 |
Chore/refactor unified logs infinite queries (#36598)
* Split unified logs count into its own infinite query and refactor main UI to use that new query * Split unified logs into its own infinite query and refactor main UI to use that new query * Shift useChartData into unified-logs-chart-query, and refactor main UI to use that new query * Rename unified-logs-query to unified-logs-infinite-query * Remove uuid and live params from query string in react queries for unified logs |