[APM] Service inventory redesign#76744
Conversation
| export function getBucketSize( | ||
| start: number, | ||
| end: number, | ||
| numBuckets: number = 100 |
There was a problem hiding this comment.
This is needed for the spark plots, where we should use less buckets because of how small the plot is.
| bucketSize: minBucketSize, | ||
| intervalString: interval, | ||
| bucketSize: 0, | ||
| intervalString: 'auto', |
There was a problem hiding this comment.
I could not find any instances where we were using anything else than 'auto', so I hardcoded the value into the function.
|
|
||
| const services = await getServices({ | ||
| setup, | ||
| mlAnomaliesEnvironment: environment, |
There was a problem hiding this comment.
Using mlAnomaliesEnvironment to make it more explicit that this should only be used for fetching anomalies, as it's already part of uiFilters in other cases.
|
Pinging @elastic/apm-ui (Team:apm) |
formgeist
left a comment
There was a problem hiding this comment.
First of all - this looks so good 😍
Made a small suggestion to the tooltip on the service name in the list.
Besides this, I found that the sparkline charts for TPM and Error rate both dip at the end. I think I recall we shifting these in our regular charts?
Additionally, I wonder how it's possible to chart the error rate for opbeans-rum when its error rate chart is empty. Looks like it's a replicate of the TPM chart.
| sortable: true, | ||
| render: (serviceName: string) => ( | ||
| render: (_, { serviceName, agentName }) => ( | ||
| <EuiToolTip content={formatString(serviceName)} id="service-name-tooltip"> |
There was a problem hiding this comment.
| <EuiToolTip content={formatString(serviceName)} id="service-name-tooltip"> | |
| <EuiToolTip delay="long" content={formatString(serviceName)} id="service-name-tooltip"> |
There was a problem hiding this comment.
I would like to delay the tooltip on the service name (since we're showing it always for truncation). It's always been a pet peeve of mine and the way we're truncating these values in our tables.
x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/HealthBadge.tsx
Outdated
Show resolved
Hide resolved
| return useFetcher( | ||
| (callApmApi) => | ||
| callApmApi({ | ||
| pathname: `/api/apm/settings/anomaly-detection`, |
There was a problem hiding this comment.
In a previous PR review I asked Oliver to change this to
| pathname: `/api/apm/settings/anomaly-detection`, | |
| pathname: `/api/apm/settings/anomaly-detection/jobs`, |
to make it obvious that it returned the jobs and to align it with POST /api/apm/settings/anomaly-detection/jobs.
However, he ran in to some typescript issues (it was not possible to have the same route twice even for different http methods).
Would you mind looking into it?
There was a problem hiding this comment.
I was thinking about fixing this when we can use template string types. We could index route definitions as POST /api/apm/settings/anomaly-detection/jobs and GET /api/apm/settings/anomaly-detection/jobs. I expect this to be easier to implement than resolving this specific issue with the options we have today. Thoughts?
There was a problem hiding this comment.
Sure, that's fine with me 👍
x-pack/plugins/apm/server/lib/services/get_services/get_services_items_stats.ts
Outdated
Show resolved
Hide resolved
| return Object.keys(anomalies.serviceAnomalies).reduce< | ||
| Array<{ serviceName: string; severity?: Severity }> | ||
| >((prev, serviceName) => { | ||
| const stats = anomalies.serviceAnomalies[serviceName]; | ||
|
|
||
| const severity = getSeverity(stats.anomalyScore); | ||
|
|
||
| return prev.concat({ | ||
| serviceName, | ||
| severity, | ||
| }); | ||
| }, []); |
There was a problem hiding this comment.
I think I commented on something similar recently: can you rewrite with [].map?
Edit: map/filter should always be preferred over reduce To explain why I find map/filter preferable over reduce: With map, without reading your implementation, I know that an array with the same length will be returned. With filter I know the length might change but the items will be identical.
reduce comes with barely any guarantees, since mostly anything can be returned. This forces the reader to spent more time understanding the implementation because it's not possible to assume much.
There was a problem hiding this comment.
map/filter should always be preferred over reduce
Not sure I agree with this. Maybe when transforming and array to another array.
reduce comes with barely any guarantees, since mostly anything can be returned
What does that mean? In this case I know an Array<{ serviceName: string; severity?: Severity }> is being returned.
There was a problem hiding this comment.
Not sure I agree with this. Maybe when transforming and array to another array.
But that's exactly it. When transforming an array to another array and keeping the same length, that's what map is for.
There was a problem hiding this comment.
To be clear, [].reduce has its place, like when you want to sum the items in an array (number[] => number). But transformations like T[] => T[] and T[] => P[] almost always become simpler with [].filter and/or [].map.
There was a problem hiding this comment.
Fwiw, this is an oversight on my part. It should have been a .map. I think I just default to reduce out of habit when using Object.keys().
| const mlJobIds = await getMLJobIds( | ||
| setup.ml.anomalyDetectors, | ||
| uiFilters.environment | ||
| ); |
smith
left a comment
There was a problem hiding this comment.
Agree with most of the comments from Soren and Casper, just here to say this is gorgeous and I love it.
| addWarning, | ||
| <EuiThemeProvider> | ||
| <MockApmPluginContextWrapper | ||
| value={ |
There was a problem hiding this comment.
This crap is way easier if you use immer.
There was a problem hiding this comment.
I think something like defaults would help here as well. Will check.
|
@formgeist I was still using errors per minute. Now that Cauê's work for |
x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts
Show resolved
Hide resolved
x-pack/plugins/apm/server/lib/services/get_services/get_services_items.ts
Show resolved
Hide resolved
x-pack/plugins/apm/server/lib/services/get_services/get_services_items_stats.ts
Outdated
Show resolved
Hide resolved
x-pack/test/apm_api_integration/basic/tests/services/top_services.ts
Outdated
Show resolved
Hide resolved
x-pack/test/apm_api_integration/trial/tests/services/top_services.ts
Outdated
Show resolved
Hide resolved
x-pack/test/apm_api_integration/trial/tests/services/top_services.ts
Outdated
Show resolved
Hide resolved
|
@elasticmachine merge upstream |
| defaultMessage: 'Critical', | ||
| } | ||
| ); | ||
| break; |
There was a problem hiding this comment.
nit: break no longer necessary
sorenlouv
left a comment
There was a problem hiding this comment.
I added a single nit but you can ignore that since you've got a green build and fixing that doesn't justify holding this up any longer.
| expectSnapshot(severityScores).toMatchInline(` | ||
| Array [ | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| "warning", | ||
| undefined, | ||
| ] | ||
| `); |
There was a problem hiding this comment.
Would it make sense to filter out undefined severity scores up front:
| expectSnapshot(severityScores).toMatchInline(` | |
| Array [ | |
| undefined, | |
| undefined, | |
| undefined, | |
| undefined, | |
| undefined, | |
| "warning", | |
| undefined, | |
| ] | |
| `); | |
| const severityScores = response.body.items.map((item: any) => item.severity).filter(Boolean); | |
| expect(severityScores.length).to.be.greaterThan(0); | |
| expectSnapshot(severityScores).toMatchInline(` | |
| Array [ | |
| "warning", | |
| ] | |
| `); |
There was a problem hiding this comment.
I think that would make sense, but it might no longer be necessary when we fix #77083. I've added it as a note there, to be able to merge this in a bit.
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
miscellaneous assets size
page load bundle size
distributable file count
History
To update your PR or re-run it, just comment with: |
* master: (26 commits) updating datatable type (elastic#77320) [ML] Fix custom URLs processing for security app (elastic#76957) [telemetry] add schema guideline + schema_check new check for --path config (elastic#75747) [ML] Transforms: API schemas and integration tests (elastic#75164) [Mappings editor] Add support for wildcard field type (elastic#76574) [Ingest Manager] Fix flyout instruction selection (elastic#77071) [Telemetry Tools] update lodash to 4.17 (elastic#77317) [APM] Service inventory redesign (elastic#76744) Hide management sections based on cluster/index privileges (elastic#67791) [Snapshot Restore] Disable steps when form is invalid (elastic#76540) [Mappings editor] Add support for positive_score_impact to rank_feature (elastic#76824) Update apm.ts (elastic#77310) [OBS] Remove beta badge, change news feed size and add external icon to news feed link (elastic#77164) [Discover] Convert legacy sort to be compatible with multi sort (elastic#76986) [APM] API Snapshot Testing (elastic#77229) [ML] Functional tests - increase wait time for DFA start (elastic#77307) [UiActions][Drilldowns] Fix actions sorting in context menu (elastic#77162) [Drilldowns] Wire up new links to new docs (elastic#77154) Fix APM issue template [Ingest Pipelines] Drop into an empty tree (elastic#76885) ...
* master: (65 commits) [Security Solution][Resolver] Analyzed event styling (elastic#77115) filter invalid SOs from the searc hresults in Task Manager (elastic#76891) [RUM Dashboard] Visitors by region map (elastic#77135) [Security Solution][Endpoint][Admin] Task/endpoint list actions (elastic#76555) [Ingest pipelines] Forms for processors T-U (elastic#76710) updating datatable type (elastic#77320) [ML] Fix custom URLs processing for security app (elastic#76957) [telemetry] add schema guideline + schema_check new check for --path config (elastic#75747) [ML] Transforms: API schemas and integration tests (elastic#75164) [Mappings editor] Add support for wildcard field type (elastic#76574) [Ingest Manager] Fix flyout instruction selection (elastic#77071) [Telemetry Tools] update lodash to 4.17 (elastic#77317) [APM] Service inventory redesign (elastic#76744) Hide management sections based on cluster/index privileges (elastic#67791) [Snapshot Restore] Disable steps when form is invalid (elastic#76540) [Mappings editor] Add support for positive_score_impact to rank_feature (elastic#76824) Update apm.ts (elastic#77310) [OBS] Remove beta badge, change news feed size and add external icon to news feed link (elastic#77164) [Discover] Convert legacy sort to be compatible with multi sort (elastic#76986) [APM] API Snapshot Testing (elastic#77229) ...
* master: (65 commits) [Security Solution][Resolver] Analyzed event styling (elastic#77115) filter invalid SOs from the searc hresults in Task Manager (elastic#76891) [RUM Dashboard] Visitors by region map (elastic#77135) [Security Solution][Endpoint][Admin] Task/endpoint list actions (elastic#76555) [Ingest pipelines] Forms for processors T-U (elastic#76710) updating datatable type (elastic#77320) [ML] Fix custom URLs processing for security app (elastic#76957) [telemetry] add schema guideline + schema_check new check for --path config (elastic#75747) [ML] Transforms: API schemas and integration tests (elastic#75164) [Mappings editor] Add support for wildcard field type (elastic#76574) [Ingest Manager] Fix flyout instruction selection (elastic#77071) [Telemetry Tools] update lodash to 4.17 (elastic#77317) [APM] Service inventory redesign (elastic#76744) Hide management sections based on cluster/index privileges (elastic#67791) [Snapshot Restore] Disable steps when form is invalid (elastic#76540) [Mappings editor] Add support for positive_score_impact to rank_feature (elastic#76824) Update apm.ts (elastic#77310) [OBS] Remove beta badge, change news feed size and add external icon to news feed link (elastic#77164) [Discover] Convert legacy sort to be compatible with multi sort (elastic#76986) [APM] API Snapshot Testing (elastic#77229) ...



Summary
Closes #75252.
Before:

After:
