Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: resolve infinite loading issue in metric view in messaging queues (#8779)

Amlan Kumar Nandy249f8be845fe
diff --git a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx
index aaf18d86ea..50d6d7efaf 100644
--- a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx
+++ b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx
@@ -6,7 +6,7 @@ import cx from 'classnames';
import { CardContainer } from 'container/GridCardLayout/styles';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { ChevronDown, ChevronUp } from 'lucide-react';
-import { useRef, useState } from 'react';
+import { useCallback, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Widgets } from 'types/api/dashboard/getAll';
@@ -129,23 +129,22 @@ function MetricPage(): JSX.Element {
},
];
- const [renderedGraphCount, setRenderedGraphCount] = useState(0);
+ const renderedGraphCountRef = useRef(0);
const hasLoggedRef = useRef(false);
- const checkIfDataExists = (isDataAvailable: boolean): void => {
+ const checkIfDataExists = useCallback((isDataAvailable: boolean): void => {
if (isDataAvailable) {
- const newCount = renderedGraphCount + 1;
- setRenderedGraphCount(newCount);
+ renderedGraphCountRef.current += 1;
// Only log when first graph has rendered and we haven't logged yet
- if (newCount === 1 && !hasLoggedRef.current) {
+ if (renderedGraphCountRef.current === 1 && !hasLoggedRef.current) {
logEvent('MQ Kafka: Metric view', {
graphRendered: true,
});
hasLoggedRef.current = true;
}
}
- };
+ }, []);
return (
<div className="metric-page">