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 Correlations: Fix chart errors caused by inconsistent histogram range steps. #138259

Merged
merged 12 commits into from
Aug 11, 2022

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Aug 8, 2022

Summary

The AreaSeries for the latency correlations charts expect the provided timestamp keys for each series to be the same, otherwise there might be errors in how the chart renders the areas. In some cases this could happen because we fetch the data for the areas independently (for example overall latency and failed transactions latency).

The fix provided by this PR adds optional durationMin and durationMax parameters to affected endpoints. This way the durationMin/Max returned by the first area request (for example "overall latency") can be passed on to the second request to enforce the same buckets/keys (for example for "failed transaction latency").

This also updates the chart code to make use of some newly available styles in Elastic Charts for orphaned points (elastic/elastic-charts#1505)

Before:

image

After:

image

Checklist

@walterra walterra added bug Fixes for quality problems that affect the customer experience release_note:fix :ml v8.4.0 v8.5.0 labels Aug 8, 2022
@walterra walterra requested a review from qn895 August 8, 2022 12:55
@walterra walterra self-assigned this Aug 8, 2022
@walterra
Copy link
Contributor Author

walterra commented Aug 8, 2022

Up for discussion: So far, as can be seen in the screenshots of the PR description, the area lines disappear when they are 0. As an alternative, we could show a continuous line:

image

@walterra walterra force-pushed the fix-latency-correlation-range-steps branch from 4c7e405 to 64fff29 Compare August 8, 2022 17:53
@walterra walterra marked this pull request as ready for review August 9, 2022 05:40
@walterra walterra requested a review from a team as a code owner August 9, 2022 05:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Aug 9, 2022
@elasticmachine
Copy link
Contributor

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

@qn895
Copy link
Member

qn895 commented Aug 9, 2022

Tested and LGTM 🎉 As for whether to show the continuous line, I think it's less crowded to not show the line when the values are 0 but have no strong opinion about it.

@formgeist
Copy link
Contributor

Up for discussion: So far, as can be seen in the screenshots of the PR description, the area lines disappear when they are 0. As an alternative, we could show a continuous line:

image

@walterra I would prefer the lines would disappear if 0 as initially proposed.

durationMax,
} = overallHistogramResponse;

const errorHistogramResponse = await callApmApi(
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered not blocking this call? So we'd render the chart with the histogram and load the errors later? We could even add an indication that errors are still being fetched on the UI.

cc: @formgeist

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 suggestion, I tweaked the loading behavior in 85b2ff2. After loading the overall histogram data we'll now already trigger an update that displays the chart with the available data and updates the progress bar. The updated jest tests also reflect the updated progress steps of the progress bar.

Comment on lines +89 to +103
const {
overallHistogram,
totalDocCount,
percentileThresholdValue,
durationMin,
durationMax,
} = await callApmApi(
'POST /internal/apm/latency/overall_distribution/transactions',
{
signal: abortCtrl.current.signal,
params: {
body: {
...fetchParams,
percentileThreshold: DEFAULT_PERCENTILE_THRESHOLD,
chartType: LatencyDistributionChartType.latencyCorrelations,
Copy link
Contributor

Choose a reason for hiding this comment

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

This call is exactly the same as the one on x-pack/plugins/apm/public/components/app/correlations/use_failed_transactions_correlations.ts do you think it is worth extracting it and reusing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we'd like to get this as a bugfix into 8.4 I'd like to avoid more refactoring, I added a comment to the meta issue in the tech debt section instead to follow up on it (Revisit hooks that fetch correlations results and possibly consolidate duplicate code like fetching the overall histogram.): #118009

<AreaSeries
key={d.id}
id={d.id}
xScaleType={ScaleType.Log}
yScaleType={ScaleType.Log}
data={replaceHistogramDotsWithBars(d.histogram)}
data={replaceHistogramZerosWithMinimumDomainValue(d.histogram)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think wrapping it on a useMemo would help? At least it wouldn't recalculate on every render.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Moved this to a useMemo() in 52cf77e.

@walterra
Copy link
Contributor Author

@formgeist @qn895 thanks for the feedback I kept original look now with the lines being interrupted when they hit 0.

@walterra
Copy link
Contributor Author

@cauemarcondes Thanks for your feedback, I addressed your comments, ready for another look.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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 3.0MB 3.0MB +493.0B

History

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

cc @walterra

@qn895
Copy link
Member

qn895 commented Aug 11, 2022

Tested latest changes and functionally LGTM 🎉

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

LGTM

@walterra walterra merged commit 3aabd88 into elastic:main Aug 11, 2022
@walterra walterra deleted the fix-latency-correlation-range-steps branch August 11, 2022 15:48
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 11, 2022
…ram range steps. (elastic#138259)

The `AreaSeries` for the latency correlations charts expect the provided timestamp keys for each series to be the same, otherwise there might be errors in how the chart renders the areas. In some cases this could happen because we fetch the data for the areas independently (for example overall latency and failed transactions latency).

The fix provided by this PR adds optional `durationMin` and `durationMax` parameters to affected endpoints. This way the `durationMin/Max` returned by the first area request (for example "overall latency") can be passed on to the second request to enforce the same buckets/keys (for example for "failed transaction latency").

(cherry picked from commit 3aabd88)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Aug 11, 2022
…ram range steps. (elastic#138259) (elastic#138637)

The `AreaSeries` for the latency correlations charts expect the provided timestamp keys for each series to be the same, otherwise there might be errors in how the chart renders the areas. In some cases this could happen because we fetch the data for the areas independently (for example overall latency and failed transactions latency).

The fix provided by this PR adds optional `durationMin` and `durationMax` parameters to affected endpoints. This way the `durationMin/Max` returned by the first area request (for example "overall latency") can be passed on to the second request to enforce the same buckets/keys (for example for "failed transaction latency").

(cherry picked from commit 3aabd88)

Co-authored-by: Walter Rafelsberger <[email protected]>
Mpdreamz pushed a commit to Mpdreamz/kibana that referenced this pull request Sep 6, 2022
…ram range steps. (elastic#138259)

The `AreaSeries` for the latency correlations charts expect the provided timestamp keys for each series to be the same, otherwise there might be errors in how the chart renders the areas. In some cases this could happen because we fetch the data for the areas independently (for example overall latency and failed transactions latency).

The fix provided by this PR adds optional `durationMin` and `durationMax` parameters to affected endpoints. This way the `durationMin/Max` returned by the first area request (for example "overall latency") can be passed on to the second request to enforce the same buckets/keys (for example for "failed transaction latency").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience :ml release_note:fix Team:APM All issues that need APM UI Team support v8.4.0 v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants