Skip to content

[APM] Load list of services from ML/terms enum#126581

Merged
dgieselaar merged 15 commits intoelastic:mainfrom
dgieselaar:front-load-services
Mar 9, 2022
Merged

[APM] Load list of services from ML/terms enum#126581
dgieselaar merged 15 commits intoelastic:mainfrom
dgieselaar:front-load-services

Conversation

@dgieselaar
Copy link
Copy Markdown
Contributor

Closes #126463.

Creates a new endpoint (GET /internal/apm/sorted_and_filtered_services) that returns a list of services based on anomaly data and the terms enum API. When environment is set, terms enum data is not returned (as it cannot be filtered). When kuery is set, ML data is not returned.

Note that GET /internal/apm/services still returns ML data - in a further iteration this might be improved, but for now this seems a good compromise in terms of scope/risk vs being fully optimised.

@dgieselaar dgieselaar added Team:APM - DEPRECATED Use Team:obs-ux-infra_services. release_note:skip Skip the PR/issue when compiling release notes v8.2.0 labels Mar 1, 2022
@dgieselaar dgieselaar requested a review from a team March 1, 2022 12:54
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Comment on lines 124 to 128
sortedAndFilteredServicesData,
sortedAndFilteredServicesStatus,
mainStatisticsData,
mainStatisticsStatus,
comparisonData,
Copy link
Copy Markdown
Member

@sorenlouv sorenlouv Mar 2, 2022

Choose a reason for hiding this comment

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

Instead of separating status from data I think we should make it a convention to pass it around as a single object:

Suggested change
sortedAndFilteredServicesData,
sortedAndFilteredServicesStatus,
mainStatisticsData,
mainStatisticsStatus,
comparisonData,
sortedAndFilteredServices,
mainStatistics,
comparison,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that make sense. Should we append something like 'fetch', e.g. sortedAndFilteredServicesFetch?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, a Fetch suffix sgtm 👍

Comment on lines +152 to +156
const isLoading =
sortedAndFilteredServicesStatus === FETCH_STATUS.LOADING ||
(sortedAndFilteredServicesStatus === FETCH_STATUS.SUCCESS &&
sortedAndFilteredServicesData?.services.length === 0 &&
mainStatisticsStatus === FETCH_STATUS.LOADING);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A little complex for a single loading state 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can break it up in variables, I don't think the logic itself would get easier, or do you have any suggestions?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't have specific suggestions - just wondering if this is a symptom of having too complex requirements for loading states. Or if this is something that can be handled more elegantly in useFetcher.

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1134 1135 +1

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.7MB 2.7MB +616.0B

History

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

Comment on lines +27 to +28
hasHistoricalData: true,
hasLegacyData: false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think hasLegacyData is leftover and should have been removed in #125962.
hasHistoricalData I'm not sure about - I don't see any references to it anywhere. Was that removed accidentally? Or perhaps we replaced that with something else when we introduced the new Observability "no data" screen?

tldr: I think both of these should be removed but please double check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hasHistoricalData was removed in #111630. It is no longer needed.

Copy link
Copy Markdown
Member

@sorenlouv sorenlouv Mar 9, 2022

Choose a reason for hiding this comment

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

However, it looks like the message is now simply saying "No services found" when there is no data.

const noItemsMessage = (
<EuiEmptyPrompt
title={
<div>
{i18n.translate('xpack.apm.servicesTable.notFoundLabel', {
defaultMessage: 'No services found',
})}
</div>
}
titleSize="s"
/>
);

It should instead say something like "No data found for selected period. Please adjust your time range and other possible filters" (because we know there is historical data available)

(fyi @MiriamAparicio)

@@ -62,17 +77,17 @@ function useServicesFetcher() {
}).then((mainStatisticsData) => {
return {
requestId: uuid(),
Copy link
Copy Markdown
Member

@sorenlouv sorenlouv Mar 9, 2022

Choose a reason for hiding this comment

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

I know you didn't add this but wouldn't it be better if useFetcher added a unique id to each response.

const mainStatisticsFetch = useFetcher();

// ...

const { requestId, data, status, error }  = mainStatisticsFetch;

);

const { mainStatisticsData, requestId } = data;
const { data: mainStatisticsData = initialData } = mainStatisticsFetch;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Probably just me being old school but I prefer this

Suggested change
const { data: mainStatisticsData = initialData } = mainStatisticsFetch;
const mainStatisticsData = mainStatisticsFetch.data ?? initialData;

Comment on lines +286 to +287
const initialSortField = displayHealthStatus ? 'healthStatus' : 'serviceName';
const initialSortDirection = displayHealthStatus ? 'desc' : 'asc';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit

Suggested change
const initialSortField = displayHealthStatus ? 'healthStatus' : 'serviceName';
const initialSortDirection = displayHealthStatus ? 'desc' : 'asc';
const initialSort = displayHealthStatus
? {field: 'healthStatus', direction: 'desc' }
: {field: 'serviceName', direction: 'asc' }

const services = joinByKey(
[
...servicesWithHealthStatuses,
...serviceNamesFromTermsEnum.map((serviceName) => ({ serviceName })),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we do this within getServicesFromTermsEnum? So it just returns a list of service names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it does return just a list of service names (ie, strings). this converts it to an object to match what should be finally returned.

Copy link
Copy Markdown
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

just nits. Feel free to merge when green

@dgieselaar dgieselaar merged commit 12f9e3c into elastic:main Mar 9, 2022
@dgieselaar dgieselaar deleted the front-load-services branch March 9, 2022 13:46
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 11, 2022
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

6 similar comments
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126581 or prevent reminders by adding the backport:skip label.

@dgieselaar dgieselaar added the backport:skip This PR does not require backporting label Mar 21, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[APM] Load list of services from just ML data + terms enum when possible

5 participants