mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## 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)
93 lines
4.3 KiB
JSON
93 lines
4.3 KiB
JSON
{
|
|
"$schema": "https://unpkg.com/knip@6/schema-jsonc.json",
|
|
// Only files + dependencies are gated in CI for now; the export/type surface
|
|
// has too much noise to enforce yet.
|
|
"exclude": ["types", "exports"],
|
|
"ignore": [
|
|
"examples/**",
|
|
"**/*.mdx",
|
|
// skip supabase functions
|
|
"supabase/functions/**",
|
|
"**/*.test.ts",
|
|
// ignore registry blocks in ui-library
|
|
"apps/ui-library/registry/default/**",
|
|
"apps/ui-library/contentlayer.config.js",
|
|
],
|
|
"workspaces": {
|
|
"apps/studio": {
|
|
// Framework-convention files: nothing in source imports these, the
|
|
// framework/host discovers them by path. They are `entry` rather than
|
|
// `ignore` so knip still traces what they import — an ignored file's
|
|
// imports are invisible, which makes everything only it pulls in look
|
|
// dead.
|
|
"entry": [
|
|
// TanStack Start. knip's tanstack-router plugin only looks under
|
|
// `src/`, but vite.config.ts sets `srcDirectory: './'`, so the
|
|
// conventional files sit at the workspace root and have to be listed.
|
|
// routeTree.gen.ts is deliberately absent: router.tsx imports it, so
|
|
// it is traced already.
|
|
"router.tsx",
|
|
"start.ts",
|
|
// Route modules are real entry points.
|
|
"routes/**/*.{ts,tsx}",
|
|
],
|
|
"ignore": [
|
|
"public/**",
|
|
// one-off build/codegen scripts, run by hand or from package.json
|
|
"scripts/**",
|
|
// dynamically imported
|
|
"components/interfaces/ConnectSheet/DirectConnectionExamples.tsx",
|
|
// data layer templates, copied when adding a new query/mutation
|
|
"data/__templates/**",
|
|
// evals are run from a GitHub action, not from the app
|
|
"evals/**",
|
|
// used from #54393 — delete this entry there
|
|
"data/logs/unified-log-trace-spans-query.ts",
|
|
],
|
|
// Narrowly scoped suppressions: one issue type, one path. Preferred over
|
|
// `ignore` (which drops the file from the project entirely, hiding the
|
|
// imports and dependencies it legitimately uses) and over
|
|
// `ignoreMembers` (which matches member names across the whole
|
|
// workspace).
|
|
"ignoreIssues": {
|
|
// graphql-codegen `client` preset output (scripts/codegen.ts,
|
|
// regenerated by `pnpm build:graphql-types`). The preset always emits
|
|
// the full set, so some of it is unreferenced by design. execute.ts in
|
|
// the same directory is hand-written and is NOT listed here.
|
|
"data/graphql/{fragment-masking,gql,graphql}.ts": ["files"],
|
|
// CONSTRAINT_TYPE mirrors the complete closed set of Postgres
|
|
// `pg_constraint.contype` values (c/f/p/u/t/x). The members we don't
|
|
// read are documentation of the valid values, not dead code. Scoped to
|
|
// this file so `enumMembers` keeps working everywhere else.
|
|
"data/database/constraints-query.ts": ["enumMembers"],
|
|
"hooks/misc/useTrackExperimentExposure.ts": ["files"],
|
|
// Staging-only pinned Postgres image + FDW request payload for creating
|
|
// Warehouse test projects by hand. Nothing imports it yet — it's kept
|
|
// alongside the rest of the Warehouse work so the values stay in one
|
|
// place until the project-creation surface that consumes them lands.
|
|
"components/interfaces/ProjectCreation/WarehouseFdwCustomImage.constants.ts": ["files"],
|
|
},
|
|
// `vercel` is a globally installed CLI used by the `deploy:staging` script
|
|
"ignoreBinaries": ["vercel"],
|
|
// Dependencies that are required implicitly — nothing imports them by a
|
|
// specifier knip can follow, but removing them breaks the build or the
|
|
// runtime.
|
|
"ignoreDependencies": [
|
|
// vite.config.ts resolves 'lodash-es/package.json' by string via
|
|
// createRequire to build the SSR lodash -> lodash-es alias
|
|
"lodash-es",
|
|
// runtime hooks for Sentry / OpenTelemetry Node
|
|
// instrumentation. Must be direct deps under pnpm's strict isolation
|
|
// (#35030).
|
|
"import-in-the-middle",
|
|
"require-in-the-middle",
|
|
// deliberate dependency-resolution pin (#45876), never imported
|
|
"@babel/core",
|
|
// provides the `tsc` binary; the typecheck script runs it through
|
|
// `maybe-turbo`, so knip can't see the usage
|
|
"@typescript/native",
|
|
],
|
|
},
|
|
},
|
|
}
|