-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Fix service maps not loading when there are no APM ML jobs #69240
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,16 @@ export async function getServiceAnomalies( | |
return []; | ||
} | ||
|
||
const { jobs: apmMlJobs } = await ml.anomalyDetectors.jobs('apm'); | ||
let apmMlJobs: AnomalyDetectionJob[] = []; | ||
try { | ||
const { jobs } = await ml.anomalyDetectors.jobs(APM_ML_JOB_GROUP_NAME); | ||
apmMlJobs = jobs; | ||
} catch (error) { | ||
// did not find any apm jobs | ||
} | ||
if (apmMlJobs.length === 0) { | ||
return []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for readability's sake, should we set apmMlJobs to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I must admit, I found it more readable to return from the catch but either works. |
||
} | ||
const apmMlJobCategories = apmMlJobs | ||
.map((job) => getApmMlJobCategory(job, serviceNames)) | ||
.filter( | ||
|
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.
Thinking more about this: I don't think we should silently swallow any error that occurs. Would be better if we can catch the error and only return under the right circumstances, and re-throw if not.
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.
WDYT about extracting to a separate function:
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.
+10000 to this.