From 5ab850935304a5b31bdea3ddfa161a7bea109bda Mon Sep 17 00:00:00 2001 From: yufansong Date: Thu, 22 Feb 2024 12:52:07 -0800 Subject: [PATCH] reduce useless call --- dashboard/pages/fragment_graph.tsx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/dashboard/pages/fragment_graph.tsx b/dashboard/pages/fragment_graph.tsx index f7b3764a6bf4a..bcc7f8cf725f6 100644 --- a/dashboard/pages/fragment_graph.tsx +++ b/dashboard/pages/fragment_graph.tsx @@ -253,18 +253,19 @@ export default function Streaming() { const toast = useErrorToast() useEffect(() => { - const interval = setInterval(() => { - const fetchNewBP = async () => { - const newBP = await getBackPressureWithoutPrometheus() - setPreviousBP(currentBP) - setCurrentBP(newBP) - } - - fetchNewBP().catch(console.error) - }, INTERVAL) + if (backPressureDataSourceAlgo === "Embedded") { + const interval = setInterval(() => { + const fetchNewBP = async () => { + const newBP = await getBackPressureWithoutPrometheus() + setPreviousBP(currentBP) + setCurrentBP(newBP) + } - return () => clearInterval(interval) - }, [currentBP]) + fetchNewBP().catch(console.error) + }, INTERVAL) + return () => clearInterval(interval) + } + }, [currentBP, backPressureDataSourceAlgo]) useEffect(() => { if (currentBP !== null && previousBP !== null) {