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

[APM] Backend operation distribution chart #134561

Merged

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Jun 16, 2022

Closes #133483.

TBD:

CleanShot 2022-06-23 at 10 03 43@2x

@dgieselaar dgieselaar added release_note:enhancement Team:APM All issues that need APM UI Team support auto-backport Deprecated: Automatically backport this PR after it's merged v8.4.0 labels Jun 16, 2022
@dgieselaar dgieselaar requested review from a team as code owners June 16, 2022 11:45
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a 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;
Copy link
Contributor

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?

Copy link
Member Author

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.

@cauemarcondes
Copy link
Contributor

@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

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, 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 />
Copy link
Contributor

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>

Copy link
Member Author

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}
Copy link
Contributor

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?

Suggested change
markerCurrentEvent={markerCurrentEvent}

Copy link
Member Author

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)

Comment on lines +67 to +69
const hasData =
(data?.allSpansDistribution.overallHistogram?.length ?? 0) > 0 ||
(data?.failedSpansDistribution.overallHistogram?.length ?? 0) > 0;
Copy link
Contributor

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:

Suggested change
const hasData =
(data?.allSpansDistribution.overallHistogram?.length ?? 0) > 0 ||
(data?.failedSpansDistribution.overallHistogram?.length ?? 0) > 0;
const hasData =
!!data?.allSpansDistribution.overallHistogram?.length ||
!!data?.failedSpansDistribution.overallHistogram?.length

Copy link
Member Author

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}
Copy link
Contributor

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?

Copy link
Member Author

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(
Copy link
Contributor

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? 😅

Copy link
Member Author

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;
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

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.

Comment on lines +39 to +46
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 }>
);
Copy link
Contributor

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?

Suggested change
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 }] );

Copy link
Member Author

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.

Comment on lines +99 to +102
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

wow it looks fancy 😎

Copy link
Member Author

Choose a reason for hiding this comment

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

😅

Comment on lines 206 to 209
// expect(finalRawResponse?.failedTransactionsCorrelations?.length).to.eql(
// 30,
// `Expected 30 identified correlations, got ${finalRawResponse?.failedTransactionsCorrelations?.length}.`
// );
Copy link
Contributor

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.

Copy link
Member Author

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.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1293 1296 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 2.9MB 2.9MB +3.7KB
Unknown metric groups

ESLint disabled line counts

id before after diff
apm 84 86 +2

Total ESLint disabled count

id before after diff
apm 98 100 +2

History

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

@dgieselaar dgieselaar merged commit ec3e3b2 into elastic:main Jun 23, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 23, 2022
@dgieselaar dgieselaar deleted the backend-operation-distribution-chart branch June 23, 2022 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated: Automatically backport this PR after it's merged backport:skip This commit does not require backporting release_note:enhancement Team:APM All issues that need APM UI Team support v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Latency distribution chart for backend operation detail view
6 participants