-
Notifications
You must be signed in to change notification settings - Fork 41
[BUGFIX] Logstable: all quries results must be included in the logs table #533
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
Conversation
|
I think this makes sense. We are now merging unordered logs, but I think sorting is done when the table renders. Can we check that? WDYT about this @rickardsjp @rafi-ruetcse17 @abelyakin? |
I see no specific mechanism for sorting or ordering mechanism. Technically, the input is rendered as it is. const logs = [...q1_results, ...q2_results]; <Virtuoso
style={{ height: '100%', flexGrow: 1 }}
initialItemCount={spec.showAll ? logs.length : undefined}
totalCount={logs.length}
itemContent={renderLogRow}
/>
/* --- */
const renderLogRow = (index: number) => {
const log = logs[index];
if (!log) return null;
return (
<LogRow
isExpandable={spec.enableDetails}
log={log}
index={index}
isExpanded={expandedRows.has(index)}
onToggle={onToggleExpand}
allowWrap={spec.allowWrap}
showTime={spec.showTime}
isSelected={selectedRows.has(index)}
onSelect={handleRowSelect}
/>
);
}; |
|
@jgbernalp
|
0118a8c to
b535a0d
Compare
jgbernalp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'll let others chime in before merging.
rickardsjp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find @shahrokni and thanks for tagging me @jgbernalp. I like it. I think we should eventually make the sorting order configurable (e.g. "flip results order" button) but that's out of scope for a bugfix PR.
logstable/src/LogsTableComponent.tsx
Outdated
| const logs = queryResults | ||
| .reduce<LogEntry[]>((acc, log) => { | ||
| acc = acc.concat(log?.data.logs?.entries ?? []); | ||
| return acc; | ||
| }, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user has more than two queries, we add the log entries multiple times, which may be bad for performance (number of copy operations grows quadratically). There is flatMap(), which I understand would make this step at least a linear operation. I've tested it locally and it also works.
| const logs = queryResults | |
| .reduce<LogEntry[]>((acc, log) => { | |
| acc = acc.concat(log?.data.logs?.entries ?? []); | |
| return acc; | |
| }, []) | |
| const logs = queryResults | |
| .flatMap(result => result?.data.logs?.entries ?? []) |
I guess that's mostly a consideration for log views with multiple queries with large results which are unlikely, but worth noting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good (reversing the timestamps) but only tests sorting and does not test whether results from multiple queries are included.
|
Lgtm. |
199c62c to
79f4d45
Compare
Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com> Signed-off-by: Mahmoud Shahrokni <seyedmahmoud.shahrokni@amadeus.com>
79f4d45 to
b8eff8e
Compare
rickardsjp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picking one last nit:
| } | ||
| }} | ||
| data-log-index={index} | ||
| data-testid={`log-row-container-${index}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we needed a new attribute here. From the docs:
Using data-testid attributes do not resemble how your software is used and should be avoided if possible.
Couldn't we have done something like
const items = items.querySelectorAll('[data-log-index]');
in the test instead?
But I think we can refactor this once we add a button for inverting the result order.

Description 🖊️
Working on perses/perses#3786 I found a bug which may also lead to other bugs related to transform. Let's see!
Logs table should include the result of all queries. It seems the buggy version only includes the query result at index 0.
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes