-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ML] APM Correlations: Chart for failed transactions correlations tab. #110172
Conversation
This reverts commit ca86f76.
params: { | ||
environment: 'ENVIRONMENT_ALL', | ||
start: '2020', | ||
end: '2021', | ||
kuery: '', | ||
percentileThreshold: 95, |
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.
nit: can use DEFAULT_PERCENTILE_THRESHOLD for this line
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. |
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.
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++) { |
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.
Can we rewrite this from a for
. Preferably replace it with map
and/or filter
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.
Refactored this to use reduce
in 0a56509.
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; | ||
} |
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.
Are you using a for
loop to ensure the promises are resolved in sequence? And what does current.histogram
do?
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 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] |
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 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[] |
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.
Same here. Using destructuring will make it easier to read
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.
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
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.
Doing in a follow-up sgtm. Thanks
@peteharverson @qn895 Fixed the width of the Score column in 869cb88 |
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.
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) |
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.
nit: Can you use flatMap here?
...flatten(data.map((d) => d.histogram)).map((d) => d.doc_count) | |
...data.flatMap((d) => d.histogram).map((d) => d.doc_count) |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @walterra |
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]>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
#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]>
Summary
Latency Distribution chart for Failed Transactions Correlations Tab
Checklist
Delete any items that are not applicable to this PR.