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
[APM] Backend operation distribution chart #134561
[APM] Backend operation distribution chart #134561
Conversation
…on-distribution-chart
…on-distribution-chart
Pinging @elastic/apm-ui (Team:apm) |
…on-distribution-chart
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.
The type change looks ok to me.
@@ -536,6 +544,7 @@ export type AggregateOf< | |||
{ | |||
doc_count: number; | |||
key: string | number; | |||
key_as_string?: string; |
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.
What's the intention of the key_as_string
optional type? Is it a workaround for the mixed key: string | number
type declaration or for ease of use?
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.
key_as_string
is returned by Elasticsearch when the terms agg runs on a boolean (and possibly numerical) field.
…on-distribution-chart
…on-distribution-chart
…on-distribution-chart
…on-distribution-chart
@dgieselaar I noticed that when comparison is toggled off the sparklines are not hiding it. Screen.Recording.2022-06-22.at.2.04.02.PM.mov |
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.
LGTM, I added some comments but they don't block it to be merged. Great work 👏🏻
@@ -42,6 +43,9 @@ export function BackendOperationDetailView() { | |||
<BackendMetricCharts /> | |||
</ChartPointerEventContextProvider> | |||
</EuiFlexItem> | |||
<EuiFlexItem> | |||
<BackendOperationDistributionChart /> |
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.
I think to match the layout of the other charts you need to wrap this inside a <EuiPanel>
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.
Thanks! That actually looks much better. I've also added it around the table.
onChartSelection={selectSampleFromChartSelection} | ||
onClearSelection={clearChartSelection} | ||
status={status} | ||
markerCurrentEvent={markerCurrentEvent} |
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.
markerCurrentEvent
is a const and initialized with undefined
can't you just omit this property?
markerCurrentEvent={markerCurrentEvent} |
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.
I can, but I prefer to be explicit about it (see line 23-24)
const hasData = | ||
(data?.allSpansDistribution.overallHistogram?.length ?? 0) > 0 || | ||
(data?.failedSpansDistribution.overallHistogram?.length ?? 0) > 0; |
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.
Isn't it the same as doing:
const hasData = | |
(data?.allSpansDistribution.overallHistogram?.length ?? 0) > 0 || | |
(data?.failedSpansDistribution.overallHistogram?.length ?? 0) > 0; | |
const hasData = | |
!!data?.allSpansDistribution.overallHistogram?.length || | |
!!data?.failedSpansDistribution.overallHistogram?.length |
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.
It is, but I prefer to explicitly check .length > 0 for readability reasons
chartData={chartData} | ||
hasData={hasData} | ||
percentileThresholdValue={percentileThresholdValue} | ||
eventType={ProcessorEvent.span} |
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.
Shouldn't this be ProcessorEvent.transaction
?
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.
Yes, thank you! It needs it to show the correct label on the y-axis.
|
||
export interface TransactionDistributionChartData { | ||
const NO_OF_TRANSACTIONS_LABEL = i18n.translate( |
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.
What does NO_OF_
stand for? 😅
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.
Number of. I'll change it to NUMBER_OF_x
} | ||
|
||
const min = resp.aggregations.duration_min.value; | ||
const max = resp.aggregations.duration_max.value * 2; |
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.
Maybe an explanation on why it is necessary to multiple by 2 would make it easier for the future.
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.
I don't really know 😅 this is all code originally written by the ML team.
} | ||
); | ||
|
||
// return early with no results if the search didn't return any documents |
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.
IMHO this comment is not necessary.
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.
Nah, but I don't feel strong enough about it to remove it either.
const ranges = rangeSteps.reduce( | ||
(p, to) => { | ||
const from = p[p.length - 1].to; | ||
p.push({ from, to }); | ||
return p; | ||
}, | ||
[{ to: 0 }] as Array<{ from?: number; to?: number }> | ||
); |
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't you do like this?
const ranges = rangeSteps.reduce( | |
(p, to) => { | |
const from = p[p.length - 1].to; | |
p.push({ from, to }); | |
return p; | |
}, | |
[{ to: 0 }] as Array<{ from?: number; to?: number }> | |
); | |
const ranges = rangeSteps.reduce<Array<{ from?: number; to?: number }> | |
>( | |
(p, to) => { | |
const from = p[p.length - 1].to; | |
p.push({ from, to }); | |
return p; | |
}, | |
[{ to: 0 }] ); |
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.
I don't think either one is much better than the other, so I will just leave it as is.
const normalizedScore = | ||
0.5 * Math.min(Math.max((bucket.score - 3.912) / 2.995, 0), 1) + | ||
0.25 * Math.min(Math.max((bucket.score - 6.908) / 6.908, 0), 1) + | ||
0.25 * Math.min(Math.max((bucket.score - 13.816) / 101.314, 0), 1); |
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.
wow it looks fancy 😎
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.
😅
// expect(finalRawResponse?.failedTransactionsCorrelations?.length).to.eql( | ||
// 30, | ||
// `Expected 30 identified correlations, got ${finalRawResponse?.failedTransactionsCorrelations?.length}.` | ||
// ); |
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 this is no longer necessary I think can be deleted.
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.
I've uncommented it, good catch.
…on-distribution-chart
…on-distribution-chart
…eselaar/kibana into backend-operation-distribution-chart
…on-distribution-chart
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Closes #133483.
TBD:
sampleRangeFrom
andsampleRangeTo
to filter the table after [APM] Display top spans for operation #134179 is merged.