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

Anomaly Charts #76889

Merged
merged 11 commits into from
Sep 5, 2024
Merged

Anomaly Charts #76889

merged 11 commits into from
Sep 5, 2024

Conversation

nhsiehgit
Copy link
Contributor

@nhsiehgit nhsiehgit commented Sep 3, 2024

highlights the alert rule details chart if an anomaly is detected

Added a dashed line to highlight when the anomaly started
and removed the label at the top of the chart
Screenshot 2024-09-03 at 3 18 23 PM
Screenshot 2024-09-03 at 3 21 35 PM

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 10.00000% with 27 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../alerts/rules/metric/details/metricChartOption.tsx 0.00% 25 Missing ⚠️
static/app/views/alerts/utils/apiCalls.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #76889      +/-   ##
==========================================
- Coverage   78.22%   78.22%   -0.01%     
==========================================
  Files        6898     6899       +1     
  Lines      306690   306718      +28     
  Branches    50276    50282       +6     
==========================================
- Hits       239919   239918       -1     
- Misses      60416    60445      +29     
  Partials     6355     6355              

@nhsiehgit
Copy link
Contributor Author

depends on #76934

Comment on lines 408 to 409
let start;
let end;
Copy link
Member

@scttcper scttcper Sep 4, 2024

Choose a reason for hiding this comment

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

start and end could use some types

Suggested change
let start;
let end;
let start: string | undefined = undefined;
let end: string | undefined = undefined;

const {anomaly, timestamp} = anomalyts;

if (
[AnomalyType.high, AnomalyType.low].indexOf(anomaly.anomaly_type as string) > -1
Copy link
Member

Choose a reason for hiding this comment

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

nit using includes instead of -1 indexof

Suggested change
[AnomalyType.high, AnomalyType.low].indexOf(anomaly.anomaly_type as string) > -1
[AnomalyType.high, AnomalyType.low].includes(anomaly.anomaly_type as string)

Comment on lines 421 to 424
if (!start) {
start = new Date(timestamp).toISOString();
}
Copy link
Member

@scttcper scttcper Sep 4, 2024

Choose a reason for hiding this comment

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

a comment here might help the next person, like what does it mean to not have the start here or when does that happen

@@ -355,6 +403,72 @@ export function getMetricAlertChartOption({
});
}

if (anomalies) {
const anomalyBlocks: any[] = [];
Copy link
Member

Choose a reason for hiding this comment

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

anomalyBlocks could use a better type

Suggested change
const anomalyBlocks: any[] = [];
const anomalyBlocks: any[] = [];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oof ok.
this was way too hairy.

not gonna bother typing this 😬

Copy link
Member

Choose a reason for hiding this comment

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

it should be MarkAreaComponentOption['data']

fetchIncidentsForRule(organization.slug, ruleId, start, end),
rulePromise,
]);
];
Copy link
Member

Choose a reason for hiding this comment

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

inserting it into the array can avoid using Promise and it should infer the types

Suggested change
];
organization.features.includes('anomaly-detection-alerts') ? fetchAnomaliesForRule(organization.slug, ruleId, start, end) : undefined
];

const {anomaly, timestamp} = anomalyts;

if (
[AnomalyType.high, AnomalyType.low].includes(anomaly.anomaly_type as string)
Copy link
Member

Choose a reason for hiding this comment

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

if its not merged yet anomalyType would be preferred but we miss this quite a bit in various endpoints

Suggested change
[AnomalyType.high, AnomalyType.low].includes(anomaly.anomaly_type as string)
[AnomalyType.high, AnomalyType.low].includes(anomaly.anomalyType as string)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh.
actually, would be dependent on the API response i guess.
I won't merge this until i've verified the api response

Copy link

codecov bot commented Sep 5, 2024

Bundle Report

Changes will increase total bundle size by 26.71kB ⬆️

Bundle name Size Change
app-webpack-bundle-array-push 30.15MB 26.71kB ⬆️

@nhsiehgit nhsiehgit enabled auto-merge (squash) September 5, 2024 22:19
@nhsiehgit nhsiehgit merged commit c0f55a5 into master Sep 5, 2024
42 of 43 checks passed
@nhsiehgit nhsiehgit deleted the nhsieh/anomaly_charts branch September 5, 2024 22:19
nhsiehgit added a commit that referenced this pull request Sep 6, 2024
<img width="92" alt="Screenshot 2024-09-05 at 3 52 14 PM"
src="https://github.com/user-attachments/assets/8ecf4050-9c00-4fe5-9828-0605a6ea6b4a">

we now have anomaly lines rendering in chartcuterie charts!

follow up to #76889
c298lee pushed a commit that referenced this pull request Sep 10, 2024
highlights the alert rule details chart if an anomaly is detected

Added a dashed line to highlight when the anomaly started
and removed the label at the top of the chart
<img width="512" alt="Screenshot 2024-09-03 at 3 18 23 PM"
src="https://github.com/user-attachments/assets/3a1a04a1-f8a0-4325-8989-f9b9f61d974a">
<img width="284" alt="Screenshot 2024-09-03 at 3 21 35 PM"
src="https://github.com/user-attachments/assets/0013642a-cbf1-488e-b88f-739cc2f92256">
c298lee pushed a commit that referenced this pull request Sep 10, 2024
<img width="92" alt="Screenshot 2024-09-05 at 3 52 14 PM"
src="https://github.com/user-attachments/assets/8ecf4050-9c00-4fe5-9828-0605a6ea6b4a">

we now have anomaly lines rendering in chartcuterie charts!

follow up to #76889
@github-actions github-actions bot locked and limited conversation to collaborators Sep 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants