-
Notifications
You must be signed in to change notification settings - Fork 23
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
refactor: Update alerting DSL verify mechanism #359
Conversation
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
@@ -55,10 +56,19 @@ export const GeneratePopoverBody: React.FC<{ | |||
const getMonitorType = async () => { | |||
const context = await incontextInsight.contextProvider?.(); |
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.
Not related to this PR, could you store this context in a variable so we don't need to invoke this provider multiple times?(It got 3 invoking for now.) contextProvider for alerting is a heavy operation, it will execute a dsl and a ppl each time.
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.
Sure, let me see how to redesign this and do it in a separate PR in order not to have any influence on upcoming release.
public/utils/alerting.ts
Outdated
export const validateToTimeRange = (time: string) => { | ||
// Alerting uses this format in to field of time range filter. | ||
const TO_TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ'; | ||
return moment.utc(time, TO_TIME_FORMAT, true).isValid(); | ||
}; | ||
|
||
export const extractTimeRangeDSL = (filters: NestedRecord[]) => { |
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.
could we add a unit test for these two functions?
setDisplayDiscoverButton(shoudDisplayDiscoverButton); | ||
let hasTimeRangeFilter = false; | ||
if (dsl) { | ||
const dslObject = JSON.parse(dsl); |
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.
add try catch for JSON.parse?
Signed-off-by: tygao <[email protected]>
(cherry picked from commit 0f4e48a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
(cherry picked from commit 0f4e48a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
Description
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.