Skip to content

chore(trace-query-builder): Improve the DX around span search bars#104757

Merged
nsdeschenes merged 17 commits intomasterfrom
nd/chore-trace-query-bar-dx-improvements
Dec 15, 2025
Merged

chore(trace-query-builder): Improve the DX around span search bars#104757
nsdeschenes merged 17 commits intomasterfrom
nd/chore-trace-query-bar-dx-improvements

Conversation

@nsdeschenes
Copy link
Copy Markdown
Contributor

The goal of this PR is to try and improve the DX of using (what was) the EAP span search bar. I've gone through and gotten rid of that component in favor of a more flexible hook to provide props for both SearchQueryBuilderProvider, and that will enable span searching with the TraceItemSearchQueryBuilder.

I've also moved the fetching of number and string attributes inside of the useEAPSpanSearchQueryBuilderProps, so it is not longer required to be passed into the useEAPSpanSearchQueryBuilderProps hook. This is to simplify some up coming work around dynamically fetching these attributes based off of the users search string while entering a key in the search query builder.

@nsdeschenes
Copy link
Copy Markdown
Contributor Author

@sentry review

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 11, 2025
Copy link
Copy Markdown
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

Looks like a nice little cleanup! The only thing I'm confused about mostly is the code about secondary aliases that got removed, how does that work?

Overall, things are still pretty confusing, would be great to resolve a few ambiguities:

  1. "EAP" vs. "TraceItem". The names of the components and hooks use both, but it's not clear when or why. Are they synonymous? Are they different? If so, why?
  2. Hooks that provide props for query builders vs. for providers. Are the providers even needed? Do the hooks need to be external to the providers, or can the providers load their own data?

This looks like a good step though 👍🏻

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #104757   +/-   ##
========================================
  Coverage   80.41%    80.42%           
========================================
  Files        9393      9393           
  Lines      403388    403340   -48     
  Branches    25923     25922    -1     
========================================
- Hits       324404    324367   -37     
+ Misses      78544     78533   -11     
  Partials      440       440           

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.

Bug: Props dropped: component ignores key configuration properties

The TraceItemSearchQueryBuilder component explicitly destructures its props but omits replaceRawSearchKeys, matchKeySuggestions, caseInsensitive, and onCaseInsensitiveClick. These props are defined in TraceItemSearchQueryBuilderProps and accepted by useTraceItemSearchQueryBuilderProps, but the component never extracts or passes them to the hook. When callers spread props like {...spanSearchQueryBuilderProps}, these configuration values are silently discarded, breaking features like raw search key replacement and case insensitivity toggles.

static/app/views/explore/components/traceItemSearchQueryBuilder.tsx#L155-L192

*/
export function TraceItemSearchQueryBuilder({
autoFocus,
initialQuery,
numberSecondaryAliases,
numberAttributes,
stringSecondaryAliases,
searchSource,
stringAttributes,
itemType,
datetime: _datetime,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates = [],
disabled,
namespace,
}: TraceItemSearchQueryBuilderProps) {
const searchQueryBuilderProps = useTraceItemSearchQueryBuilderProps({
itemType,
numberAttributes,
stringAttributes,
numberSecondaryAliases,
stringSecondaryAliases,
initialQuery,
searchSource,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates,
namespace,
});

Fix in Cursor Fix in Web


Bug: Placeholder prop ignored in search query builder hook

The useTraceItemSearchQueryBuilderProps hook does not destructure the placeholder prop from its parameters. The type includes placeholder via the intersection with SpanSearchQueryBuilderProps, but the hook ignores it and always computes a default placeholder via itemTypeToDefaultPlaceholder(itemType). Multiple callers pass custom placeholder values like t('Search for span attributes') which are silently discarded, resulting in incorrect placeholder text.

static/app/views/explore/components/traceItemSearchQueryBuilder.tsx#L64-L86

export function useTraceItemSearchQueryBuilderProps({
itemType,
numberAttributes,
numberSecondaryAliases,
stringAttributes,
stringSecondaryAliases,
initialQuery,
searchSource,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates = [],
namespace,
replaceRawSearchKeys,
matchKeySuggestions,
caseInsensitive,
onCaseInsensitiveClick,
}: TraceItemSearchQueryBuilderProps) {
const placeholderText = itemTypeToDefaultPlaceholder(itemType);

Fix in Cursor Fix in Web


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.

Bug: Component drops props for case sensitivity and search features

The TraceItemSearchQueryBuilder component accepts TraceItemSearchQueryBuilderProps but its function signature omits caseInsensitive, onCaseInsensitiveClick, matchKeySuggestions, and replaceRawSearchKeys. These props are passed by callers (via spanSearchQueryBuilderProps from useSpanSearchQueryBuilderProps) but silently dropped, causing features like case-insensitive search toggle and key suggestions to not function. The props need to be destructured and passed to useTraceItemSearchQueryBuilderProps.

static/app/views/explore/components/traceItemSearchQueryBuilder.tsx#L155-L192

*/
export function TraceItemSearchQueryBuilder({
autoFocus,
initialQuery,
numberSecondaryAliases,
numberAttributes,
stringSecondaryAliases,
searchSource,
stringAttributes,
itemType,
datetime: _datetime,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates = [],
disabled,
namespace,
}: TraceItemSearchQueryBuilderProps) {
const searchQueryBuilderProps = useTraceItemSearchQueryBuilderProps({
itemType,
numberAttributes,
stringAttributes,
numberSecondaryAliases,
stringSecondaryAliases,
initialQuery,
searchSource,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates,
namespace,
});

Fix in Cursor Fix in Web


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.

Bug: Props not forwarded to internal hook in component

The TraceItemSearchQueryBuilder component accepts caseInsensitive, matchKeySuggestions, onCaseInsensitiveClick, and replaceRawSearchKeys in its props type, but doesn't destructure them or pass them to useTraceItemSearchQueryBuilderProps. The hook expects and uses these props (lines 81-84), so when callers pass them to the component, they are silently ignored. This breaks case insensitivity toggle, raw search key replacement, and key suggestion features when using this component directly.

static/app/views/explore/components/traceItemSearchQueryBuilder.tsx#L155-L192

*/
export function TraceItemSearchQueryBuilder({
autoFocus,
initialQuery,
numberSecondaryAliases,
numberAttributes,
stringSecondaryAliases,
searchSource,
stringAttributes,
itemType,
datetime: _datetime,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates = [],
disabled,
namespace,
}: TraceItemSearchQueryBuilderProps) {
const searchQueryBuilderProps = useTraceItemSearchQueryBuilderProps({
itemType,
numberAttributes,
stringAttributes,
numberSecondaryAliases,
stringSecondaryAliases,
initialQuery,
searchSource,
getFilterTokenWarning,
onBlur,
onChange,
onSearch,
portalTarget,
projects,
supportedAggregates,
namespace,
});

Fix in Cursor Fix in Web


@nsdeschenes nsdeschenes merged commit ddade87 into master Dec 15, 2025
49 checks passed
@nsdeschenes nsdeschenes deleted the nd/chore-trace-query-bar-dx-improvements branch December 15, 2025 13:33
@github-actions github-actions bot locked and limited conversation to collaborators Dec 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants