Skip to content

Added Search in Trace detail#424

Merged
BYK merged 8 commits intomainfrom
feat/search-trace-detail
Jun 28, 2024
Merged

Added Search in Trace detail#424
BYK merged 8 commits intomainfrom
feat/search-trace-detail

Conversation

@Shubhdeep12
Copy link
Collaborator

Before opening this PR:

Screencast.from.06-23-2024.07.28.07.PM.webm

@vercel
Copy link

vercel bot commented Jun 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
spotlightjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 11:15pm

@Shubhdeep12 Shubhdeep12 requested review from HazAT and Lms24 June 23, 2024 14:00
Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

Mainly rejecting for debounce issue. But please take a look at my other comments too.

Comment on lines +49 to +51
const isQueried = query
? span.op?.includes(query) || span.description?.includes(query) || span.span_id.includes(query)
: false;
Copy link
Member

Choose a reason for hiding this comment

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

I'd put the check for description last as that'd be the most expensive check I presume (due to length?)

Suggested change
const isQueried = query
? span.op?.includes(query) || span.description?.includes(query) || span.span_id.includes(query)
: false;
const isQueried = query
? span.span_id.includes(query) || span.op?.includes(query) || span.description?.includes(query)
: false;

Also not a fan of those op? and description? optionals but I'm guessing we have to live with it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it can be possible of having spans here without op or description. so we need a check here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely i'll make the change suggested above

</div>
<div
className="waterfall"
className={classNames('waterfall', isQueried ? '!bg-transparent' : '')}
Copy link
Member

Choose a reason for hiding this comment

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

Not happy that we had do spread query and isQueried around so much. I understand that this is kind of the result of us using classNames instead of creating specific CSS classes/styled components. Is there a way out of this? :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that is because of tailwind CSS.
Although if needed we can pass the classnames and create the styles in .css files.

totalDuration={totalDuration}
spanNodeWidth={spanNodeWidth}
setSpanNodeWidth={setSpanNodeWidth}
query={query}
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if this should be passed in the context at this point. Have you considered that?

Copy link
Collaborator Author

@Shubhdeep12 Shubhdeep12 Jun 27, 2024

Choose a reason for hiding this comment

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

hmm, yes we can use context here as well.
should i create one or we can fix it as a whole in sentry integration for other states as well in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

should i create one or we can fix it as a whole in sentry integration for other states as well in a separate PR?

Separate PR as I understand there are more things we can move to context from what you say.

@@ -0,0 +1,17 @@
import { useEffect, useState } from 'react';

export default function useDebounce<T>(value: T, delay: number): T {
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely NOT proper debouncing. It just delays setting the value. A real debounce would not change anything until the last update + debounce period. It also looks like this code was lifted from https://github.com/uidotdev/usehooks/blob/90fbbb4cc085e74e50c36a62a5759a40c62bb98e/index.js#L239-L253. If that's the case, we should give a reference back there.

Finally, if you want to have proper debouncing this answer seems like the way: https://stackoverflow.com/a/75556586/90297. The one below that also shows "the hook way" with useMemo and proper cancellation as it apparently uses the debounce decorater from lodash.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @BYK

https://github.com/uidotdev/usehooks/blob/90fbbb4cc085e74e50c36a62a5759a40c62bb98e/index.js#L239-L253. If that's the case, we should give a reference back there.

No, not lifted from here.

Finally, if you want to have proper debouncing this answer seems like the way: https://stackoverflow.com/a/75556586/90297. The one below that also shows "the hook way" with useMemo and proper cancellation as it apparently uses the debounce decorater from lodash.

Sure, let me enhance the hook based on the example above.
But since we are debouncing search. here we will have to maintain 2 states - one for instantly updating the search query in input(this cannot be debounced) and another for passing the search query in children components(this one will be debounced).

Copy link
Member

Choose a reason for hiding this comment

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

But since we are debouncing search. here we will have to maintain 2 states - one for instantly updating the search query in input(this cannot be debounced) and another for passing the search query in children components(this one will be debounced).

Not against debouncing, on the contrary I like it. It's just the debouncing logic is not right here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, even i found that an issue, because we were setting the state again and again in hook, which was not an efficient solution and that would cost us multiple re-renders.

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

It's okay but I think your initial pass where useDebounce was containing the logic was better. This version feels a bit less polished and usable.

To emphasize: my main issue was the debounce logic not being correct in the initial version. It seems to be fixed in this version.

@BYK BYK merged commit 01321f8 into main Jun 28, 2024
@BYK BYK deleted the feat/search-trace-detail branch June 28, 2024 23:19
kensternberg-authentik added a commit to kensternberg-authentik/spotlight that referenced this pull request Jul 15, 2024
…rybook-8-compatibility

* origin/HEAD:
  fix: Overhaul envelope parsing to be spec compliant (getsentry#439)
  fix: Always trim befor trying to JSON.parse (getsentry#438)
  Highlighted active span and event (getsentry#437)
  ref: Use new event helpers (getsentry#433)
  fix: Remove forgotton console.log statement
  feat: POC for adding spotlight overlay for ssr-errors (getsentry#364)
  ref: More concise event helpers (getsentry#431)
  fix: Fix CI issues (getsentry#432)
  fix: Send something immediately to trigger open event (getsentry#429)
  ref: More robust client init code generation (getsentry#426)
  docs: Add note about Volta - pnpm support (getsentry#425)
  Added Search in Trace detail (getsentry#424)
  Added Trace Info (getsentry#423)
  chore(deps-dev): bump vite from 4.5.2 to 4.5.3 (getsentry#392)
  chore(deps): bump braces from 3.0.2 to 3.0.3 (getsentry#415)
  docs: Add build step to initial setup (getsentry#418)
BYK pushed a commit that referenced this pull request Jul 22, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @spotlightjs/astro@2.1.0

### Minor Changes

- A new Vite plugin under the main `@spotlightjs/spotlight` package that
automatically injects spotlight for dev mode.
It ([#434](#434)) also
replaces Vite's error page shown on compilation
    errors with Spotlight.

- 1. Altered the ssr-page vite plugin in @spotlight/astro to run
spotlight overlay in fullscreen mode in ssr-error page.
        ([#364](#364))
    2.  Closed astro erro overlay.
3. Added a option in sentry integration to open first error encountered
in spotlight automatically.

### Patch Changes

-   Updated dependencies

\[[`a8c09cd8629677ab3eed4bf7000de4c7068538ee`](a8c09cd)]:
    -   @spotlightjs/spotlight@2.1.0

## @spotlightjs/overlay@2.1.0

### Minor Changes

- 1. Altered the ssr-page vite plugin in @spotlight/astro to run
spotlight overlay in fullscreen mode in ssr-error page.
        ([#364](#364))
    2.  Closed astro erro overlay.
3. Added a option in sentry integration to open first error encountered
in spotlight automatically.

### Patch Changes

- Added search bar in trace
([#424](#424))

- - Show active span item in trace when span info is opened.
([#437](#437))
- Show active event in DeveloperInfo tab when event is info is opened.

- added traceInfo
([#423](#423))

- Overhaul envelope parsing to be spec compliant
([#439](#439))

## @spotlightjs/sidecar@1.5.0

### Minor Changes

- A new Vite plugin under the main `@spotlightjs/spotlight` package that
automatically injects spotlight for dev mode.
It ([#434](#434)) also
replaces Vite's error page shown on compilation
    errors with Spotlight.

## @spotlightjs/spotlight@2.1.0

### Minor Changes

- A new Vite plugin under the main `@spotlightjs/spotlight` package that
automatically injects spotlight for dev mode.
It ([#434](#434)) also
replaces Vite's error page shown on compilation
    errors with Spotlight.

### Patch Changes

-   Updated dependencies

\[[`01321f8824ae133dc02a1d829c25952c884bf631`](01321f8),

[`a8c09cd8629677ab3eed4bf7000de4c7068538ee`](a8c09cd),

[`3792a5e742b3888a980a0b865fd23be941809040`](3792a5e),

[`b5249aa761c783739543dc7bf27cdd8d0fe8cebe`](b5249aa),

[`1c7896e02a2b81715c4e5c47cbb2fd6145868ab1`](1c7896e),

[`41d90455fa94df0a01e93fd90574974dfca96764`](41d9045)]:
    -   @spotlightjs/overlay@2.1.0
    -   @spotlightjs/sidecar@1.5.0

## @spotlightjs/electron@1.0.1

### Patch Changes

-   Updated dependencies

\[[`01321f8824ae133dc02a1d829c25952c884bf631`](01321f8),

[`a8c09cd8629677ab3eed4bf7000de4c7068538ee`](a8c09cd),

[`3792a5e742b3888a980a0b865fd23be941809040`](3792a5e),

[`b5249aa761c783739543dc7bf27cdd8d0fe8cebe`](b5249aa),

[`1c7896e02a2b81715c4e5c47cbb2fd6145868ab1`](1c7896e),

[`41d90455fa94df0a01e93fd90574974dfca96764`](41d9045)]:
    -   @spotlightjs/overlay@2.1.0
    -   @spotlightjs/sidecar@1.5.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Shubhdeep12 added a commit that referenced this pull request Mar 8, 2025
<!--
Tick these boxes if they're applicable to your PR.
- Changesets are only required for PRs to Spotlight library packages
(e.g. @spotlightjs/overlay). Not for the website/docs or demo app
contributions.
- Typo correction or small bugfix PRs don't require an issue. If you're
making a bigger change, please open an issue first.
-->

Before opening this PR:

- [x] I added a [Changeset
Entry](https://spotlightjs.com/contribute/changesets/) with `pnpm
changeset:add`
- [ ] I referenced issues that this PR addresses


- Added back Search input
- used context for search query(related
#424 (comment))
  - we can extend this and make a context only for trace detail.
- added a hook for search input

---------

Co-authored-by: Burak Yigit Kaya <byk@sentry.io>
dcramer pushed a commit that referenced this pull request Jun 3, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @spotlightjs/astro@2.1.0

### Minor Changes

- A new Vite plugin under the main `@spotlightjs/spotlight` package that
automatically injects spotlight for dev mode.
It ([#434](#434)) also
replaces Vite's error page shown on compilation
    errors with Spotlight.

- 1. Altered the ssr-page vite plugin in @spotlight/astro to run
spotlight overlay in fullscreen mode in ssr-error page.
        ([#364](#364))
    2.  Closed astro erro overlay.
3. Added a option in sentry integration to open first error encountered
in spotlight automatically.

### Patch Changes

-   Updated dependencies

\[[`a8c09cd8629677ab3eed4bf7000de4c7068538ee`](a8c09cd)]:
    -   @spotlightjs/spotlight@2.1.0

## @spotlightjs/overlay@2.1.0

### Minor Changes

- 1. Altered the ssr-page vite plugin in @spotlight/astro to run
spotlight overlay in fullscreen mode in ssr-error page.
        ([#364](#364))
    2.  Closed astro erro overlay.
3. Added a option in sentry integration to open first error encountered
in spotlight automatically.

### Patch Changes

- Added search bar in trace
([#424](#424))

- - Show active span item in trace when span info is opened.
([#437](#437))
- Show active event in DeveloperInfo tab when event is info is opened.

- added traceInfo
([#423](#423))

- Overhaul envelope parsing to be spec compliant
([#439](#439))

## @spotlightjs/sidecar@1.5.0

### Minor Changes

- A new Vite plugin under the main `@spotlightjs/spotlight` package that
automatically injects spotlight for dev mode.
It ([#434](#434)) also
replaces Vite's error page shown on compilation
    errors with Spotlight.

## @spotlightjs/spotlight@2.1.0

### Minor Changes

- A new Vite plugin under the main `@spotlightjs/spotlight` package that
automatically injects spotlight for dev mode.
It ([#434](#434)) also
replaces Vite's error page shown on compilation
    errors with Spotlight.

### Patch Changes

-   Updated dependencies

\[[`01321f8824ae133dc02a1d829c25952c884bf631`](01321f8),

[`a8c09cd8629677ab3eed4bf7000de4c7068538ee`](a8c09cd),

[`3792a5e742b3888a980a0b865fd23be941809040`](3792a5e),

[`b5249aa761c783739543dc7bf27cdd8d0fe8cebe`](b5249aa),

[`1c7896e02a2b81715c4e5c47cbb2fd6145868ab1`](1c7896e),

[`41d90455fa94df0a01e93fd90574974dfca96764`](41d9045)]:
    -   @spotlightjs/overlay@2.1.0
    -   @spotlightjs/sidecar@1.5.0

## @spotlightjs/electron@1.0.1

### Patch Changes

-   Updated dependencies

\[[`01321f8824ae133dc02a1d829c25952c884bf631`](01321f8),

[`a8c09cd8629677ab3eed4bf7000de4c7068538ee`](a8c09cd),

[`3792a5e742b3888a980a0b865fd23be941809040`](3792a5e),

[`b5249aa761c783739543dc7bf27cdd8d0fe8cebe`](b5249aa),

[`1c7896e02a2b81715c4e5c47cbb2fd6145868ab1`](1c7896e),

[`41d90455fa94df0a01e93fd90574974dfca96764`](41d9045)]:
    -   @spotlightjs/overlay@2.1.0
    -   @spotlightjs/sidecar@1.5.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
dcramer pushed a commit that referenced this pull request Jun 3, 2025
<!--
Tick these boxes if they're applicable to your PR.
- Changesets are only required for PRs to Spotlight library packages
(e.g. @spotlightjs/overlay). Not for the website/docs or demo app
contributions.
- Typo correction or small bugfix PRs don't require an issue. If you're
making a bigger change, please open an issue first.
-->

Before opening this PR:

- [x] I added a [Changeset
Entry](https://spotlightjs.com/contribute/changesets/) with `pnpm
changeset:add`
- [ ] I referenced issues that this PR addresses


- Added back Search input
- used context for search query(related
#424 (comment))
  - we can extend this and make a context only for trace detail.
- added a hook for search input

---------

Co-authored-by: Burak Yigit Kaya <byk@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants