Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Query Editor: UI improvements and Lucene query type selection improvements #583

Merged
merged 5 commits into from
Mar 25, 2025

Conversation

idastambuk
Copy link
Contributor

@idastambuk idastambuk commented Mar 7, 2025

What this PR does / why we need it:

Our current editor hides Logs, Raw Data and Raw Document under Metrics dropdown, which isn't very intuitive. This refactor the editor to add a few new things:

  1. Adds Lucene Query Selector component, which will update luceneQueryType and metrics values, depending on the selection(logs, raw data, raw document - traces isn't included as a metric in the current query model). N.B. this doesn't change the query model, so even after this Logs and Raw Document queries will have their respective metrics. This is to not to have to deal with migrations, which would be a much bigger feature and should be done separately from this.
  2. Improves display for Alias field - it is only supported with time series queries, i.e. queries with date histogram bucket aggregation
  3. Adds an option Size in Logs ,which already exists in the backend, but it seems we have never sent it in the frontend query object. Without this input the Logs Settings collapse is empty which looks weird, but I can add it in another PR instead.
Screenshot 2025-03-07 at 15 41 01 Screenshot 2025-03-07 at 15 41 12 Screenshot 2025-03-07 at 15 42 10

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Testing:

  1. Create some queries of different types in main, then checkout to this branch and make sure they don't break.
  2. Make sure the saved queries can be edited, lucene query type changed, and that everything works as intended
  3. Make sure creating new queries works as intended and query type can be changed, metrics added etc.

@idastambuk idastambuk requested a review from a team as a code owner March 7, 2025 14:55
@idastambuk idastambuk requested review from kevinwcyu and njvrzm and removed request for a team March 7, 2025 14:55

export const UPDATE_LUCENE_TYPE_AND_METRICS = 'update_lucene_type_and_metrics';

export const updateLuceneTypeAndMetrics = createAction<{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updateLuceneTypeAndMetrics updates two reducers (this one and metricsReducer) at the same time,.
This is because, if I triggered onChange(query) from the component and then changeMetricType, one would overwrite the other (changeMetricType calls onChange in the background)

@idastambuk idastambuk linked an issue Mar 7, 2025 that may be closed by this pull request
Copy link
Contributor

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

A couple style nits, but I tried it and it looks good!

</>
{props.query.luceneQueryType === LuceneQueryType.Traces && (
<EditorRow>
<InlineField label="Service Map" tooltip={'Request and display service map data for trace(s)'}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably could be a separate pr, but we could probably update these to match the other query type options more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, did it in this one!
Screenshot 2025-03-24 at 19 19 32

)}
</>
)}
{metric.type === 'logs' && (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: If this is the same as the size field above would it make sense to have the condition for that be (metric.type === 'raw_data' || metric.type === 'raw_document' || metric.type === 'logs') instead repeating it again?

expect(screen.queryByLabelText('Alias')).toBeNull();
});

it('Should be shown if last bucket aggregation is Date Histogram', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this test have more than 1 bucket arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed!

return getNewMetrics(state || [], action.payload.id, action.payload.type);
}
if (updateLuceneTypeAndMetrics.match(action)) {
return action.payload.metrics;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: from a code organization perspective, it feels a little weird that changeMetricType calls getNewMetrics here and updateLuceneTypeAndMetrics calls it in the LuceneQueryTypeSelector when it dispatches the action

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to send metric type and id instead of metrics, so just reducer will call getNewMetrics

@idastambuk idastambuk linked an issue Mar 24, 2025 that may be closed by this pull request
@idastambuk idastambuk merged commit e5f7823 into main Mar 25, 2025
13 checks passed
@idastambuk idastambuk deleted the query-editor-revamp branch March 25, 2025 15:19
@idastambuk idastambuk mentioned this pull request Mar 25, 2025
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.

Query Editor: Update Layout to make selecting query type easier Move non-metric based queries out of metric
2 participants