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

[Exploratory view] Only show metric loading for relevant series #118299

Merged
merged 2 commits into from
Nov 12, 2021

Conversation

shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Nov 11, 2021

Summary

Fixes: #117275

Will only show loading for relevant series when index pattern is loading

If index pattenr is already loaded, it won't show the loading

Added relevant unit tests to reflect the change.

@shahzad31 shahzad31 marked this pull request as ready for review November 11, 2021 09:50
@shahzad31 shahzad31 requested a review from a team as a code owner November 11, 2021 09:50
@shahzad31 shahzad31 self-assigned this Nov 11, 2021
@shahzad31 shahzad31 added release_note:skip Skip the PR/issue when compiling release notes v7.16.0 v8.0.0 labels Nov 11, 2021
@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Default Firefox Tests / Spaces app Enter Space allows user to navigate to different spaces, respecting the configured default route

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observability 379.1KB 379.1KB -4.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @shahzad31

Copy link
Contributor

@lucasfcosta lucasfcosta left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @shahzad31!

I've tested it as I've done before, and it looks good to me. As you can see in the GIF below, as I load new metrics the old ones don't show as loading too.

not_loading_all

I've only left non-blocking comments. I'll leave it up to you if you think they're worth addressing.

@@ -127,7 +127,7 @@ export function ReportMetricOptions({ seriesId, series, seriesConfig }: Props) {
</EuiPopover>
)}
{series.selectedMetricField &&
(indexPattern && !loading ? (
(indexPattern ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand this will work because if we get here and decide not to display the EuiLoadingSpinner that's because we've already done the loading for this particular pattern.

As I was reading code, however, I had to mentally attempt quite a few combinations of state to try to think of edge cases.

As a note for a further improvement (which we don't have to incorporate in this PR unless you want/have time to), I can make the following suggestion:

  1. Pass series.dataType to the hook invocation on L38
  2. Change the value of loading that's passed to IndexPatternContext.Provider so that it embeds the whole map informing which metrics are loading not only if we're loading any metrics
  3. In the component itself, access the loading state for a particular series.dataType.

Such a change would allow us to determine whether a particular metric is loading, not only whether any metrics are loading at all.

IMO I think it would also be clearer to the reader that we display the loading because a particular metric is loading, not because of a combination of previous states (and early returns).

});

it('should display loading if index pattern is not available and is loading', async function () {
mockAppIndexPattern({ loading: true, indexPatterns: undefined });
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make the test a bit more robust, it may be worth adding other indexPatterns to the dictionary object here so that your test could prove that the component checks for that index pattern in particular:

i.e.

    mockAppIndexPattern({ loading: true, indexPatterns: { "other-index-pattern": true } });

This is also minor and non-blocking.

@shahzad31 shahzad31 added the auto-backport Deprecated - use backport:version if exact versions are needed label Nov 12, 2021
@shahzad31 shahzad31 merged commit 0b4ede7 into elastic:main Nov 12, 2021
@shahzad31 shahzad31 deleted the fix-metric-reload branch November 12, 2021 11:33
@kibanamachine
Copy link
Contributor

The following labels were identified as gaps in your version labels and will be added automatically:

  • v8.1.0

If any of these should not be on your pull request, please manually remove them.

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0
7.16

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Nov 12, 2021
) (#118459)

Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
kibanamachine added a commit that referenced this pull request Nov 12, 2021
) (#118460)

Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
roeehub pushed a commit to build-security/kibana that referenced this pull request Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.16.0 v8.0.0 v8.1.0
Projects
None yet
3 participants