Skip to content

chore(explore): Migrate logs and spans to nuqs#116278

Draft
nsdeschenes wants to merge 12 commits into
masterfrom
nd/chore-explore-migrate-logs-and-spans-to-nuqs
Draft

chore(explore): Migrate logs and spans to nuqs#116278
nsdeschenes wants to merge 12 commits into
masterfrom
nd/chore-explore-migrate-logs-and-spans-to-nuqs

Conversation

@nsdeschenes
Copy link
Copy Markdown
Contributor

This PR is an attempt to migrate the query params for logs and spans from react router over to nuqs.

Extract reusable nuqs parsers (mode, extrapolate, fields, sortBys,
groupBys, visualizes, aggregateFields, crossEvents) and a
serializeQueryParamsToLocation helper. Export parseAggregateField,
parseCrossEvents, and validateSort so the parsers can use them.
Replace manual location/navigate wiring in SpansQueryParamsProvider
with nuqs useQueryStates. Add getReadableQueryParamsFromParsed and
getSpansQueryParamsUpdate to work with parsed nuqs values. Export
key constants so the provider can reference them directly.
Replace manual location/navigate wiring in LogsLocationQueryParamsProvider
with nuqs useQueryStates. Add getReadableQueryParamsFromParsed and
getLogsQueryParamsUpdate to work with parsed nuqs values. Legacy
aggregate params (logsAggregate, logsAggregateParam, logsGroupBy)
are cleared when aggregateFields are set.
Replace direct navigate calls with useSetQueryParamsAggregateCursor
in AggregatesTable and add useSetQueryParamsAggregateSortBys onClick
handler in LogsAggregateTable so sorting works through context
setters instead of only through link href.
@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@sentry review

@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@cursor review

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.58% 93.58% ±0%
Typed 133,171 133,250 🟢 +79
Untyped 9,133 9,142 🔴 +9
🔍 9 new type safety issues introduced

any-typed symbols (6 new)

File Line Detail
static/app/views/explore/logs/logsQueryParams.tsx 176 update (var)
static/app/views/explore/queryParams/aggregateField.ts 58 aggregateFields (param)
static/app/views/explore/queryParams/aggregateField.ts 60 aggregateField (param)
static/app/views/explore/queryParams/nuqsParsers.ts 76 value (var)
static/app/views/explore/queryParams/nuqsParsers.ts 95 value (var)
static/app/views/explore/spans/spansQueryParams.tsx 195 update (var)

Non-null assertions (!) (1 new)

File Line Detail
static/app/views/explore/queryParams/nuqsParsers.ts 135 allValues[0]!

Type assertions (as) (2 new)

File Line Detail
static/app/views/explore/queryParams/nuqsParsers.ts 131 `as {type?: string}
static/app/views/explore/queryParams/nuqsParsers.ts 131 as keyof Parserskey as keyof Parsers

This is informational only and does not block the PR.

Comment thread static/app/views/explore/logs/logsQueryParams.tsx Outdated
nsdeschenes and others added 4 commits May 27, 2026 08:00
Move defaultMode, defaultCursor, getValidSortBys, getValidAggregateSortBys,
and normalizeAggregateFields from logs/spans queryParams into shared modules
to eliminate identical copy-pasted implementations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Un-export constants, types, and functions that are only used internally.
Remove dead isDefaultFields functions from logs and spans query params.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix serializeQueryParamsToLocation to preserve array types for
  multi-parser values instead of collapsing single-element arrays
- Fix SentryNuqsTestingAdapter to read from location.query when
  location.search is empty, matching how test mocks set query params
- Migrate useTab to route mode and table changes through nuqs
  setQueryParams instead of direct navigate calls
- Stabilize readableQueryParams memoization in providers to prevent
  extra re-renders from nuqs reference changes
- Add table param to spansQueryParamsParsers and WritableQueryParams
- Use renderHookWithProviders in useStreamingTimeseriesResult tests

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Keep parsed span query params in sync with local writes while nuqs updates the URL, and preserve referenced aggregate fields when switching modes.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5c773d3. Configure here.

Comment thread static/app/views/explore/tables/aggregatesTable.tsx
Comment thread static/app/views/explore/spans/spansQueryParams.tsx Outdated
Remove the spans query-param optimistic mirror and use the Explore query-param API for attribute breakdown tab changes instead of rebuilding the URL from location.query.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
nsdeschenes and others added 2 commits May 27, 2026 12:23
When Pagination emits an undefined aggregate cursor, remove the aggregate cursor query parameter so the table returns to page 1.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Move the common aggregate field defaulting logic into the shared query params helper so spans and logs use the same implementation.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant