-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: updated the logic for variable update queue #6586
base: main
Are you sure you want to change the base?
Conversation
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
2 similar comments
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
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.
❌ Changes requested. Reviewed everything up to fa4aeae in 1 minute and 38 seconds
More details
- Looked at
307
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
4
drafted comments based on config settings.
1. frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts:33
- Draft comment:
ThegetDependentVariables
function is duplicated in multiple files. Consider defining it in a single location and importing it where needed to avoid redundancy and potential inconsistencies. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The comment is speculative because it assumes the function is duplicated in other files, but the diff does not provide evidence of this. Without evidence, the comment does not meet the criteria for a necessary code change.
I might be missing context from other files that are not shown in the diff. The function could indeed be duplicated elsewhere, but I have no way to verify this from the current information.
Given the rules, I should only consider the information presented in the diff. Without evidence of duplication in the diff, the comment should be removed.
Remove the comment because it is speculative and not based on evidence from the diff.
2. frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx:99
- Draft comment:
ThevalidVariableUpdate
function's logic for checking if the component is mounted is inverted. It should return true if the component is mounted and the variable is in the update queue, not the other way around. Consider revising the logic. - Reason this comment was not posted:
Comment looked like it was already resolved.
3. frontend/src/container/NewDashboard/DashboardVariablesSelection/VariableItem.tsx:95
- Draft comment:
TheuseEffect
that setsisMounted.current
to true is missing a dependency array. Add an empty dependency array to ensure this effect only runs once when the component mounts. - Reason this comment was not posted:
Comment looked like it was already resolved.
4. frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts:33
-
Draft comment:
This function is duplicated. Consider importing and reusing the existing implementation instead. -
function
getDependentVariables
(VariableItem.tsx) -
Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_so46fFL9ZJXaSHHK
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
@cxposition - Hey, it seems like there is some issue with composite queries, and it seems like you are missing configs there, so can you please share the URL of this above scenario? It will help with the debugging. |
I'm sorry that the company's Intranet environment cannot be provided, maybe it is our configuration problem, we will investigate and solve it first, and I will share with you as soon as there is any progress, thank you for your reply. |
The problem is resolved. It is a configuration problem.Thanks for your reply. |
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
@@ -21,6 +26,11 @@ function DashboardVariableSelection(): JSX.Element | null { | |||
|
|||
const [variablesTableData, setVariablesTableData] = useState<any>([]); | |||
|
|||
const [dependencyData, setDependencyData] = useState<{ | |||
order: string[]; | |||
graph: VariableGraph; |
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.
extract out to independent type , IDependencyData
const initializationRef = useRef(false); | ||
|
||
useEffect(() => { | ||
if (variablesTableData.length > 0 && !initializationRef.current) { |
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.
why is this required ?
- since the initial state of dependency data is null, a null check would be sufficient to know the first load ?
- on similar lines we do not want to re-calculate the deps graph / order when
variablesTableData
is updated ? when adding or removing variables from the dashboard ?
@@ -88,18 +89,26 @@ function VariableItem({ | |||
(state) => state.globalTime, | |||
); | |||
|
|||
// logic to detect if its a rerender or a new render/mount | |||
const isMounted = useRef(false); |
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.
why is onMount
handling different ? onMount
should be handled via the root triggers ?
@@ -29,3 +29,110 @@ export const convertVariablesToDbFormat = ( | |||
result[id] = obj; | |||
return result; | |||
}, {}); | |||
|
|||
const getDependentVariables = (queryValue: string): string[] => { | |||
const variableRegexPattern = /\{\{\s*?\.([^\s}]+)\s*?\}\}/g; |
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.
we do support a bunch of other variable formats as well, please do include them as well
} | ||
|
||
if (topologicalOrder.length !== Object.keys(dependencies).length) { | ||
throw new Error('Cycle detected in the dependency graph!'); |
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.
we want to break the UI here ? maybe show some user consumable error here ? or detect this while saving the variables so that this doesn't occur ?
allSelected, | ||
isMounted.current, | ||
); | ||
setVariablesToGetUpdated((prev) => |
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.
onValueUpdate
should be responsible to remove the variable from variablesToGetUpdated
?
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
… variables (#6609) * feat: added API limiting to reduce unneccesary api call for dashboard variables * feat: fixed dropdown open triggering the api calls for single-select and misc
…sors - dashboardVariables (#6621) * feat: added API limiting to reduce unneccesary api call for dashboard variables * feat: fixed dropdown open triggering the api calls for single-select and misc * feat: add jest test cases for new logic's utils, functions and processors - dashboardVariables * feat: added test for checkAPIInvocation * feat: refactor code * feat: added more test on graph utilities
1abf809
to
5097375
Compare
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
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.
❌ Changes requested. Incremental review on 5097375 in 32 seconds
More details
- Looked at
518
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. frontend/src/container/NewDashboard/DashboardVariablesSelection/util.ts:49
- Draft comment:
Remove the console.log statement to clean up the code.
- Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_opWqhmMAiMrrkLH0
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
export const buildDependencies = ( | ||
variables: IDashboardVariable[], | ||
): VariableGraph => { | ||
console.log('buildDependencies', variables); |
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.
Remove the console.log statement to avoid unnecessary console output.
console.log('buildDependencies', variables); |
@SagarRajput-7 is this point about not resetting already selected values https://www.notion.so/signoz/Dashboard-Variables-8783d02224c0483b9e8a4b8218cb5ddc?pvs=4#144fcc6bcd1980dda2c2ede018f29914. Is it part of this PR? or is it yet to be implemented? |
Summary
Under this change I have introduced the following things -
For more info refer to the
Technical Analysis and new approach
block of this notion doc - https://www.notion.so/signoz/Dashboard-Variables-8783d02224c0483b9e8a4b8218cb5ddc?pvs=4#2c0617c157a141f5a09ba261d9d15d4dRelated Issues / PR's
Screenshots
Comparison between local and prod env
Screen.Recording.2024-12-04.at.10.15.42.AM.mov
Affected Areas and Manually Tested Areas
Tested before and after of -
Important
Replaces variable update queue with a dependency graph in dashboard variable management, adding new utility functions and tests.
DashboardVariableSelection.tsx
.onValueUpdate
to handle mounted and non-mounted calls.onVarChanged
function.buildDependencies
,buildDependencyGraph
,buildParentDependencyGraph
, andonUpdateVariableNode
inutil.ts
.validVariableUpdate
logic inVariableItem.tsx
.dashboardVariables.test.tsx
.useRef
for initialization checks inDashboardVariableSelection.tsx
andVariableItem.tsx
.VariableItem.tsx
.This description was created by for 5097375. It will automatically update as commits are pushed.