[APM] Load list of services from ML/terms enum#126581
[APM] Load list of services from ML/terms enum#126581dgieselaar merged 15 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/apm-ui (Team:apm) |
| sortedAndFilteredServicesData, | ||
| sortedAndFilteredServicesStatus, | ||
| mainStatisticsData, | ||
| mainStatisticsStatus, | ||
| comparisonData, |
There was a problem hiding this comment.
Instead of separating status from data I think we should make it a convention to pass it around as a single object:
| sortedAndFilteredServicesData, | |
| sortedAndFilteredServicesStatus, | |
| mainStatisticsData, | |
| mainStatisticsStatus, | |
| comparisonData, | |
| sortedAndFilteredServices, | |
| mainStatistics, | |
| comparison, |
There was a problem hiding this comment.
I think that make sense. Should we append something like 'fetch', e.g. sortedAndFilteredServicesFetch?
| const isLoading = | ||
| sortedAndFilteredServicesStatus === FETCH_STATUS.LOADING || | ||
| (sortedAndFilteredServicesStatus === FETCH_STATUS.SUCCESS && | ||
| sortedAndFilteredServicesData?.services.length === 0 && | ||
| mainStatisticsStatus === FETCH_STATUS.LOADING); |
There was a problem hiding this comment.
A little complex for a single loading state 😅
There was a problem hiding this comment.
I can break it up in variables, I don't think the logic itself would get easier, or do you have any suggestions?
There was a problem hiding this comment.
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.
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
| hasHistoricalData: true, | ||
| hasLegacyData: false, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
hasHistoricalData was removed in #111630. It is no longer needed.
There was a problem hiding this comment.
However, it looks like the message is now simply saying "No services found" when there is no data.
kibana/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx
Lines 127 to 138 in 8b82657
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(), | |||
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
nit: Probably just me being old school but I prefer this
| const { data: mainStatisticsData = initialData } = mainStatisticsFetch; | |
| const mainStatisticsData = mainStatisticsFetch.data ?? initialData; |
| const initialSortField = displayHealthStatus ? 'healthStatus' : 'serviceName'; | ||
| const initialSortDirection = displayHealthStatus ? 'desc' : 'asc'; |
There was a problem hiding this comment.
nit
| 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 })), |
There was a problem hiding this comment.
Can we do this within getServicesFromTermsEnum? So it just returns a list of service names?
There was a problem hiding this comment.
it does return just a list of service names (ie, strings). this converts it to an object to match what should be finally returned.
sorenlouv
left a comment
There was a problem hiding this comment.
just nits. Feel free to merge when green
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
6 similar comments
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
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. Whenenvironmentis set, terms enum data is not returned (as it cannot be filtered). Whenkueryis set, ML data is not returned.Note that
GET /internal/apm/servicesstill 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.