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

[ML] APM Latency Correlations: Fix empty state #109813

Merged
merged 16 commits into from
Aug 27, 2021

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Aug 24, 2021

Summary

Fixes #109608.
Fixes #109879.

  • Correctly renders the empty chart state when no data is available.
  • Hides the "Click drag to select" and trace samples message when the chart shows an empty state to avoid redundant info.
  • Adds jest unit tests that would fail with the previously visible loading indicators.

Previous:

image

Updated:

image

Checklist

@walterra walterra added bug Fixes for quality problems that affect the customer experience Team:APM All issues that need APM UI Team support :ml v8.0.0 release_note:skip Skip the PR/issue when compiling release notes apm:correlations v7.15.0 v7.16.0 labels Aug 24, 2021
@walterra walterra self-assigned this Aug 24, 2021
@walterra walterra marked this pull request as ready for review August 24, 2021 11:46
@walterra walterra requested a review from a team as a code owner August 24, 2021 11:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested and LGTM.

Not related, but I think the text in the tooltips for the Failure and Success columns in the Failed transactions tabs needs an edit to replace appear with appears.

image

image

@walterra
Copy link
Contributor Author

@peteharverson Fixed the tooltip text in ca86f76. Also fixed #109879 in cc7f8f1, the code changes would be overlapping if doing it in a separate PR.

@formgeist
Copy link
Contributor

@walterra Noticed a small change in the empty prompt where the word-break is now showing the two paragraphs too far apart. I think we need to remove the 2 <p>'s and instead just add a <br /> in between. Can you include this fix in this PR?

Current

CleanShot 2021-08-25 at 11 39 23@2x

<EuiText size="s">
              <p>
                <FormattedMessage
                  id="xpack.apm.correlations.noCorrelationsTextLine1"
                  defaultMessage="Correlations will only be identified if they have significant impact."
                />
              </p>
              <p>
                <FormattedMessage
                  id="xpack.apm.correlations.noCorrelationsTextLine2"
                  defaultMessage="Try selecting another time range or remove any added filter."
                />
              </p>
            </EuiText>

Proposed

<EuiText size="s">
              <p>
                <FormattedMessage
                  id="xpack.apm.correlations.noCorrelationsTextLine1"
                  defaultMessage="Correlations will only be identified if they have significant impact."
                />
                <br />
                <FormattedMessage
                  id="xpack.apm.correlations.noCorrelationsTextLine2"
                  defaultMessage="Try selecting another time range or remove any added filter."
                />
              </p>
            </EuiText>

CleanShot 2021-08-25 at 11 41 22@2x

@walterra
Copy link
Contributor Author

@formgeist good catch! fixed in 137b14e.

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested latest changes and LGTM

@@ -95,7 +95,7 @@ export function FailedTransactionsCorrelations({
const startFetchHandler = useCallback(() => {
startFetch(searchServicePrams);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [environment, serviceName, kuery, start, end]);
}, [environment, serviceName, transactionType, kuery, start, end]);
Copy link
Member

Choose a reason for hiding this comment

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

This bug occurred because we have eslint suppress errors. Why do we do that in the first place? Can we remove it?
Also: looking at this it looks like we are still missing transactionName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved in 34e882c. We originally had it there because the callback startFetch/cancelFetch were reinstantiated on every hook call. I wrapped them in useCallback so that doesn't happen anymore.

@@ -117,11 +132,10 @@ export function TransactionDistribution({

return () => {
// cancel any running async partial request when unmounting the component
// we want this effect to execute exactly once after the component mounts
cancelFetch();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

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

Same as above: can we remove the lint supression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to keep it here because isRunning is in there as a safety measure to cancel a still running service on a refresh, but don't want to trigger on every isRunning change. I added a comment to make it more clear.

);

useEffect(() => {
if (typeof onHasData === 'function') {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this typed so it can only be () => void | undefined or something like that? In that case we know it's a function if it's not undefined:

Suggested change
if (typeof onHasData === 'function') {
if (onHasData) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Usually I try to write these ifs similar to "How would we write this if we'd move it to a type guard?" to be a bit more strict at runtime. It won't make much a difference in this case of course because it's just us consuming the component and it's not dynamic data.

@walterra walterra added the auto-backport Deprecated - use backport:version if exact versions are needed label Aug 26, 2021
@sorenlouv
Copy link
Member

As a general comment: it is somtimes hard to see where the separation between Kibana Search service logic and the correlation business logic.

I noticed a lot of duplication between the following files:

Data fetchers

  • x-pack/plugins/apm/public/hooks/use_failed_transactions_correlations_fetcher.ts
  • x-pack/plugins/apm/public/hooks/use_transaction_latency_correlations_fetcher.ts
  • x-pack/plugins/apm/public/hooks/use_transaction_distribution_fetcher.ts

Search strategies

  • x-pack/plugins/apm/server/lib/search_strategies/correlations/search_strategy.ts
  • x-pack/plugins/apm/server/lib/search_strategies/failed_transactions_correlations/search_strategy.ts

Search services

  • x-pack/plugins/apm/server/lib/search_strategies/failed_transactions_correlations/async_search_service.ts
  • x-pack/plugins/apm/server/lib/search_strategies/correlations/async_search_service.ts

Having some generic abstractions on top of Kibana Search service would go along way. We both need it on the server, and something similar to useFetcher on the client.

@walterra
Copy link
Contributor Author

Because we worked in parallel on similar features in separate PRs, we decided to go with duplicate code for 7.15 to make FF and avoid running out of sync or put a burden on us with more complex merge conflicts. Now that everything is in master there's definitely room for a lot of deduplication.

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested latest edits and LGTM

@walterra
Copy link
Contributor Author

@elasticmachine merge upstream

@walterra walterra enabled auto-merge (squash) August 27, 2021 08:53
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

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
apm 4.4MB 4.4MB +2.1KB

History

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

cc @walterra

@walterra walterra merged commit 54a45bb into elastic:master Aug 27, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 27, 2021
- Correctly renders the empty chart state when no data is available.
- Hides the "Click drag to select" and trace samples message when the chart shows an empty state to avoid redundant info.
- Adds jest unit tests that would fail with the previously visible loading indicators.
- Fix a bug with cancelling search strategies.
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.15 Commit could not be cherrypicked due to conflicts
7.x

Successful backport PRs will be merged automatically after passing CI.

To backport manually run:
node scripts/backport --pr 109813

@walterra walterra deleted the ml-apm-correlations-fix-empty-state branch August 27, 2021 11:18
kibanamachine added a commit that referenced this pull request Aug 27, 2021
- Correctly renders the empty chart state when no data is available.
- Hides the "Click drag to select" and trace samples message when the chart shows an empty state to avoid redundant info.
- Adds jest unit tests that would fail with the previously visible loading indicators.
- Fix a bug with cancelling search strategies.

Co-authored-by: Walter Rafelsberger <[email protected]>
walterra added a commit that referenced this pull request Aug 27, 2021
- Correctly renders the empty chart state when no data is available.
- Hides the "Click drag to select" and trace samples message when the chart shows an empty state to avoid redundant info.
- Adds jest unit tests that would fail with the previously visible loading indicators.
- Fix a bug with cancelling search strategies.
# Conflicts:
#	x-pack/plugins/apm/public/components/app/correlations/latency_correlations.tsx
#	x-pack/plugins/apm/public/components/app/transaction_details/distribution/index.tsx
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 30, 2021
…eporting-to-v2

* 'master' of github.com:elastic/kibana: (120 commits)
  [Lens] should register "suffix" field formatter in setup lifecycle (elastic#110218)
  skip flaky suite (elastic#98463)
  skip flaky suite (elastic#108633)
  [Data Table] Expensive queries are causing unnecessary load and delays on Elasticsearch (elastic#98903)
  fixes failing tests (elastic#110436)
  [TSVB] Remove deprecated `IFieldType` (elastic#110404)
  [Lens] Remove deprecated `IFieldType` (elastic#109825)
  [Vega] Expensive queries are causing unnecessary load and delays on Elasticsearch (elastic#99023)
  [Visualizations] Expensive queries are causing unnecessary load and delays on Elasticsearch (elastic#99031)
  [TSVB] Expensive queries are causing unnecessary load and delays on Elasticsearch (elastic#98914)
  Don't add split part of UI if we have one series (elastic#109483)
  [Discover] Migrate angular routing to react router (elastic#107042)
  [Security Solution][Endpoint][Event Filters] Fixes missing spacers between event filters cards (elastic#110282)
  [ML] Data Grid: Fix alignment of sorting arrow when histogram charts are enabled (elastic#110053)
  [canvas] Fix image argument form issues (elastic#109767)
  Fix asset in Pitch template (elastic#109742)
  chore(NA): moving @kbn/securitysolution-list-api to babel transpiler (elastic#110265)
  chore(NA): moving @kbn/securitysolution-list-constants to babel transpiler (elastic#110269)
  [Fleet] Fix upgrade link in Fleet policy table (elastic#110228)
  [ML] APM Latency Correlations: Fix empty state (elastic#109813)
  ...

# Conflicts:
#	src/plugins/data/common/query/timefilter/types.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:correlations auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience :ml release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v7.15.0 v7.16.0 v8.0.0
Projects
None yet
6 participants