Skip to content

feat(insights): Add sort parameter to support to span samples endpoint #89230

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

gggritso
Copy link
Member

@gggritso gggritso commented Apr 9, 2025

Right now the results are always sorted by timestamp, and the frontend sometimes manually sorts them by duration. That seems strange, why not just support sorting on the backend instead?

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 9, 2025
@gggritso gggritso marked this pull request as ready for review April 9, 2025 22:41
@gggritso gggritso requested a review from a team as a code owner April 9, 2025 22:41
@mjq
Copy link
Member

mjq commented Apr 10, 2025

why not just support sorting on the backend instead?

I approved this, but the only reason I can think of is to avoid expensive potential sorts (timestamp is probably known to be cheapest) - @wmak might have more context. @gggritso you might want to check with him before merge just in case

Copy link
Member

@wmak wmak left a comment

Choose a reason for hiding this comment

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

We filter by id first before the orderby so it should... be ok 👍

@gggritso gggritso merged commit 5fa6894 into master Apr 10, 2025
61 checks passed
@gggritso gggritso deleted the georgegritsouk/dain-187-add-ordering-parameter-to-span-samples-endpoint branch April 10, 2025 16:44
Copy link

sentry-io bot commented Apr 10, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ UnqualifiedQueryError: Validation failed for entity spans: Tag keys (nan) not resolved /api/0/organizations/{organization_id_or_slug}/... View Issue

Did you find this useful? React with a 👍 or 👎

gggritso added a commit that referenced this pull request Apr 11, 2025
There are two `useSpanSamples` hooks. One from the HTTP panel, and one
"generic" one, used for Queries, Assets, Mobile, etc. The second
"generic" one is more fancy, since it calculates its own bounds. I'm
going to combine the two hooks soon to eliminate the duplication, but
this is a first step to unblock some other work.

- add types to `additionalFields`. This also improves type safety of the
responses
- align the parameters passed to `useApiQuery` from the two hooks. They
used to have different stale time and behaviour for some reason
- have both the `useSpanSamples` hooks return data _and_ meta. Without
meta, I can't plot these samples on new charts, so this unlocks that
behaviour
- remove manual sorting from the hook. One of the hooks manually sorted
the samples by duration. This is not necessary as of
#89230 (so, I need to wait for
that PR before I deploy this)
andrewshie-sentry pushed a commit that referenced this pull request Apr 22, 2025
…int (#89230)

Right now the results are always sorted by timestamp, and the frontend
sometimes manually sorts them by duration. That seems strange, why not
just support sorting on the backend instead?
andrewshie-sentry pushed a commit that referenced this pull request Apr 22, 2025
There are two `useSpanSamples` hooks. One from the HTTP panel, and one
"generic" one, used for Queries, Assets, Mobile, etc. The second
"generic" one is more fancy, since it calculates its own bounds. I'm
going to combine the two hooks soon to eliminate the duplication, but
this is a first step to unblock some other work.

- add types to `additionalFields`. This also improves type safety of the
responses
- align the parameters passed to `useApiQuery` from the two hooks. They
used to have different stale time and behaviour for some reason
- have both the `useSpanSamples` hooks return data _and_ meta. Without
meta, I can't plot these samples on new charts, so this unlocks that
behaviour
- remove manual sorting from the hook. One of the hooks manually sorted
the samples by duration. This is not necessary as of
#89230 (so, I need to wait for
that PR before I deploy this)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants