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: Chart for failed transactions correlations tab. #110172

Merged

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Aug 26, 2021

Summary

Latency Distribution chart for Failed Transactions Correlations Tab

image

  • Updates the distribution chart component to be able to retrieve data for an array of area instead of the previously hard coded 2 area.
  • Updates server side query functions to accept an array of term filters instead of just a single field/value pair.
  • The colors for the areas are definitely up for discussion (we can adapt them in a follow up after a feedback round).

Checklist

Delete any items that are not applicable to this PR.

@walterra walterra self-assigned this Aug 26, 2021
params: {
environment: 'ENVIRONMENT_ALL',
start: '2020',
end: '2021',
kuery: '',
percentileThreshold: 95,
Copy link
Member

Choose a reason for hiding this comment

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

nit: can use DEFAULT_PERCENTILE_THRESHOLD for this line

@qn895
Copy link
Member

qn895 commented Sep 9, 2021

Just noticed the column sizes look off when es inspect mode is off. Would be good to have the Field name column have more space here.
Screen Shot 2021-09-09 at 09 18 34

The colors are also bit hard to distinguish for me, especially when some of areas overlap.

Screen.Recording.2021-09-09.at.09.32.48.mov

@peteharverson
Copy link
Contributor

The score column is getting too much width for me, with or without the es inspect on. As @qn895 suggested, would be good to give the field name / value columns more width.

image

@peteharverson
Copy link
Contributor

peteharverson commented Sep 9, 2021

Is it worth adding the (subsequently removed for 7.15) lines about the chart from 2d14d2a to the help popover?

(added this to the 7.16 meta issue #109220)

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 overall looks good. Would be good to reduce the width of the score column, and identify better colours to use in the chart, but that polish can be added in a follow-up.

histogram[i + 1].doc_count = CHART_PLACEHOLDER_VALUE;
}

for (let i = 0; i < histogram.length - 1; i++) {
Copy link
Member

@sorenlouv sorenlouv Sep 9, 2021

Choose a reason for hiding this comment

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

Can we rewrite this from a for. Preferably replace it with map and/or filter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored this to use reduce in 0a56509.

Comment on lines 115 to 129
for (let i = 0; i < result.length; i++) {
const current = result[i];

const histogram = await fetchTransactionDurationRanges(
esClient,
params,
histogramRangeSteps,
[
{ fieldName: EVENT_OUTCOME, fieldValue: EventOutcome.failure },
{ fieldName: current.fieldName, fieldValue: current.fieldValue },
]
);

current.histogram = histogram;
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you using a for loop to ensure the promises are resolved in sequence? And what does current.histogram do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a bit of a leftover from experimentation. I refactored it to get rid of the current and use for of in
95f4a49. It's sequential by intention because we don't know how many calls there could be to avoid hammering ES.

@@ -69,8 +71,7 @@ export async function* fetchTransactionDurationHistograms(
esClient,
params,
histogramRangeSteps,
item.fieldName,
item.fieldValue
[item]
Copy link
Member

Choose a reason for hiding this comment

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

If you destructure the arguments this function become much easier to read. Right now it's pretty opaque what [item] is.

@@ -23,10 +23,9 @@ import { SIGNIFICANT_VALUE_DIGITS } from '../constants';
export const getTransactionDurationPercentilesRequest = (
params: SearchStrategyParams,
percents?: number[],
fieldName?: FieldValuePair['fieldName'],
fieldValue?: FieldValuePair['fieldValue']
termFilters?: FieldValuePair[]
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Using destructuring will make it easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To do this consistently for all queries would require to refactor more files than the ones already touched in this PR, unrelated to the feature. I added an item to the meta issue to pick it up in a follow up #109220

Copy link
Member

Choose a reason for hiding this comment

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

Doing in a follow-up sgtm. Thanks

@walterra
Copy link
Contributor Author

walterra commented Sep 9, 2021

@peteharverson @qn895 Fixed the width of the Score column in 869cb88

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.

Reduced width for score column and latest changes LGTM.

I added an item for updating the failed transaction tab help popover with info on the chart to #109220

@@ -137,15 +131,15 @@ export function TransactionDistributionChart({

// This will create y axis ticks for 1, 10, 100, 1000 ...
const yMax =
Math.max(...(overallHistogram ?? []).map((d) => d.doc_count)) ?? 0;
Math.max(
...flatten(data.map((d) => d.histogram)).map((d) => d.doc_count)
Copy link
Member

@sorenlouv sorenlouv Sep 13, 2021

Choose a reason for hiding this comment

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

nit: Can you use flatMap here?

Suggested change
...flatten(data.map((d) => d.histogram)).map((d) => d.doc_count)
...data.flatMap((d) => d.histogram).map((d) => d.doc_count)

@peteharverson
Copy link
Contributor

@elasticmachine merge upstream

@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 +1.6KB

History

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

cc @walterra

@peteharverson peteharverson merged commit 065701a into elastic:master Sep 13, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 13, 2021
elastic#110172)

* [ML] Fix tooltip text.

* Revert "[ML] Fix tooltip text."

This reverts commit ca86f76.

* [ML] Chart prototype.

* [ML] Hover support for failed transactions chart.

* [ML] Add p-value column.

* [ML] Code consolidation.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Consolidate hooks.

* [ML] Consolidate hooks.

* [ML] Consolidate hooks.

* [ML] Use function overloads.

* [ML] Fix naming inconsistencies.

* [ML] Fix jest test.

* [ML] Fix chart loading behavior.

* [ML] Rename values to latencyCorrelations.

* [ML] Clean up types.

* [ML] Add function overloads.

* [Ml] Update API integration tests.

* [ML] Rename values to failedTransactionsCorrelations.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Fix jest test.

* [ML] Fix API integration test

* [ML] Clean up chart data.

* [ML] Fix chart props.

* [ML] Tweak types for failed correlations.

* [ML] Improve FieldValuePair type usage.

* [ML] Remove 'async' from variable names.

* [ML] Fix typo.

* [ML] Simplify mock.

* [ML] Refactor code that used type guards.

* [ML] Comment about feature availability.

* [ML] Simplify check.

* [ML] Simplify selectedHistogram.

* [ML] Improve column type safety.

* [ML] Simplify selectedTerm.

* [ML] Simplify sorting.

* [ML] Fix regresssion when there's no data for failed transactions.

* [ML] Rename fieldFilter to termFilters.

* [ML] Update api integration test assertions.

* [ML] Fix failed transactions params.

* [ML] Tweak chart title.

* [ML] Tweak chart colors.

* [ML] Add translation.

* [ML] Tweak selectedTerm if statement.

* [ML] Fix types.

* [ML] Fix assertion text.

* [ML] Refactor replaceHistogramDotsWithBars.

* [ML] Refactor fetchFailedTransactionsCorrelationPValues.

* [ML] Fix score column width.

Co-authored-by: Kibana Machine <[email protected]>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 13, 2021
#110172) (#111983)

* [ML] Fix tooltip text.

* Revert "[ML] Fix tooltip text."

This reverts commit ca86f76.

* [ML] Chart prototype.

* [ML] Hover support for failed transactions chart.

* [ML] Add p-value column.

* [ML] Code consolidation.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Consolidate hooks.

* [ML] Consolidate hooks.

* [ML] Consolidate hooks.

* [ML] Use function overloads.

* [ML] Fix naming inconsistencies.

* [ML] Fix jest test.

* [ML] Fix chart loading behavior.

* [ML] Rename values to latencyCorrelations.

* [ML] Clean up types.

* [ML] Add function overloads.

* [Ml] Update API integration tests.

* [ML] Rename values to failedTransactionsCorrelations.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Fix naming inconsistencies.

* [ML] Fix jest test.

* [ML] Fix API integration test

* [ML] Clean up chart data.

* [ML] Fix chart props.

* [ML] Tweak types for failed correlations.

* [ML] Improve FieldValuePair type usage.

* [ML] Remove 'async' from variable names.

* [ML] Fix typo.

* [ML] Simplify mock.

* [ML] Refactor code that used type guards.

* [ML] Comment about feature availability.

* [ML] Simplify check.

* [ML] Simplify selectedHistogram.

* [ML] Improve column type safety.

* [ML] Simplify selectedTerm.

* [ML] Simplify sorting.

* [ML] Fix regresssion when there's no data for failed transactions.

* [ML] Rename fieldFilter to termFilters.

* [ML] Update api integration test assertions.

* [ML] Fix failed transactions params.

* [ML] Tweak chart title.

* [ML] Tweak chart colors.

* [ML] Add translation.

* [ML] Tweak selectedTerm if statement.

* [ML] Fix types.

* [ML] Fix assertion text.

* [ML] Refactor replaceHistogramDotsWithBars.

* [ML] Refactor fetchFailedTransactionsCorrelationPValues.

* [ML] Fix score column width.

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Walter Rafelsberger <[email protected]>
@walterra walterra deleted the ml-apm-failed-transactions-chart branch October 18, 2021 12:17
@peteharverson peteharverson added release_note:feature Makes this part of the condensed release notes and removed release_note:enhancement labels Nov 2, 2021
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 :ml release_note:feature Makes this part of the condensed release notes Team:APM All issues that need APM UI Team support v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants