mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 22:29:02 +08:00
chore: added sentry alert for dashboard when query_range not called (#6791)
This commit is contained in:
parent
68ee677630
commit
d6bfd95302
@ -44,6 +44,7 @@ function GridCardGraph({
|
|||||||
toScrollWidgetId,
|
toScrollWidgetId,
|
||||||
setToScrollWidgetId,
|
setToScrollWidgetId,
|
||||||
variablesToGetUpdated,
|
variablesToGetUpdated,
|
||||||
|
setDashboardQueryRangeCalled,
|
||||||
} = useDashboard();
|
} = useDashboard();
|
||||||
const { minTime, maxTime, selectedTime: globalSelectedInterval } = useSelector<
|
const { minTime, maxTime, selectedTime: globalSelectedInterval } = useSelector<
|
||||||
AppState,
|
AppState,
|
||||||
@ -202,11 +203,13 @@ function GridCardGraph({
|
|||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setErrorMessage(error.message);
|
setErrorMessage(error.message);
|
||||||
|
setDashboardQueryRangeCalled(true);
|
||||||
},
|
},
|
||||||
onSettled: (data) => {
|
onSettled: (data) => {
|
||||||
dataAvailable?.(
|
dataAvailable?.(
|
||||||
isDataAvailableByPanelType(data?.payload?.data, widget?.panelTypes),
|
isDataAvailableByPanelType(data?.payload?.data, widget?.panelTypes),
|
||||||
);
|
);
|
||||||
|
setDashboardQueryRangeCalled(true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import './GridCardLayout.styles.scss';
|
import './GridCardLayout.styles.scss';
|
||||||
|
|
||||||
|
import * as Sentry from '@sentry/react';
|
||||||
import { Color } from '@signozhq/design-tokens';
|
import { Color } from '@signozhq/design-tokens';
|
||||||
import { Button, Form, Input, Modal, Typography } from 'antd';
|
import { Button, Form, Input, Modal, Typography } from 'antd';
|
||||||
import { useForm } from 'antd/es/form/Form';
|
import { useForm } from 'antd/es/form/Form';
|
||||||
@ -61,6 +62,8 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
|
|||||||
setPanelMap,
|
setPanelMap,
|
||||||
setSelectedDashboard,
|
setSelectedDashboard,
|
||||||
isDashboardLocked,
|
isDashboardLocked,
|
||||||
|
dashboardQueryRangeCalled,
|
||||||
|
setDashboardQueryRangeCalled,
|
||||||
} = useDashboard();
|
} = useDashboard();
|
||||||
const { data } = selectedDashboard || {};
|
const { data } = selectedDashboard || {};
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
@ -124,6 +127,25 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
|
|||||||
setDashboardLayout(sortLayout(layouts));
|
setDashboardLayout(sortLayout(layouts));
|
||||||
}, [layouts]);
|
}, [layouts]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setDashboardQueryRangeCalled(false);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
// Send Sentry event if query_range is not called within expected timeframe (2 mins) when there are widgets
|
||||||
|
if (!dashboardQueryRangeCalled && data?.widgets?.length) {
|
||||||
|
Sentry.captureEvent({
|
||||||
|
message: `Dashboard query range not called within expected timeframe even when there are ${data?.widgets?.length} widgets`,
|
||||||
|
level: 'warning',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 120000);
|
||||||
|
|
||||||
|
return (): void => clearTimeout(timeoutId);
|
||||||
|
}, [dashboardQueryRangeCalled, data?.widgets?.length]);
|
||||||
|
|
||||||
const logEventCalledRef = useRef(false);
|
const logEventCalledRef = useRef(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!logEventCalledRef.current && !isUndefined(data)) {
|
if (!logEventCalledRef.current && !isUndefined(data)) {
|
||||||
|
@ -69,6 +69,8 @@ const DashboardContext = createContext<IDashboardContext>({
|
|||||||
updateLocalStorageDashboardVariables: () => {},
|
updateLocalStorageDashboardVariables: () => {},
|
||||||
variablesToGetUpdated: [],
|
variablesToGetUpdated: [],
|
||||||
setVariablesToGetUpdated: () => {},
|
setVariablesToGetUpdated: () => {},
|
||||||
|
dashboardQueryRangeCalled: false,
|
||||||
|
setDashboardQueryRangeCalled: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -85,6 +87,11 @@ export function DashboardProvider({
|
|||||||
|
|
||||||
const [isDashboardLocked, setIsDashboardLocked] = useState<boolean>(false);
|
const [isDashboardLocked, setIsDashboardLocked] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [
|
||||||
|
dashboardQueryRangeCalled,
|
||||||
|
setDashboardQueryRangeCalled,
|
||||||
|
] = useState<boolean>(false);
|
||||||
|
|
||||||
const isDashboardPage = useRouteMatch<Props>({
|
const isDashboardPage = useRouteMatch<Props>({
|
||||||
path: ROUTES.DASHBOARD,
|
path: ROUTES.DASHBOARD,
|
||||||
exact: true,
|
exact: true,
|
||||||
@ -407,6 +414,8 @@ export function DashboardProvider({
|
|||||||
updateLocalStorageDashboardVariables,
|
updateLocalStorageDashboardVariables,
|
||||||
variablesToGetUpdated,
|
variablesToGetUpdated,
|
||||||
setVariablesToGetUpdated,
|
setVariablesToGetUpdated,
|
||||||
|
dashboardQueryRangeCalled,
|
||||||
|
setDashboardQueryRangeCalled,
|
||||||
}),
|
}),
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[
|
[
|
||||||
@ -424,6 +433,8 @@ export function DashboardProvider({
|
|||||||
currentDashboard,
|
currentDashboard,
|
||||||
variablesToGetUpdated,
|
variablesToGetUpdated,
|
||||||
setVariablesToGetUpdated,
|
setVariablesToGetUpdated,
|
||||||
|
dashboardQueryRangeCalled,
|
||||||
|
setDashboardQueryRangeCalled,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -43,4 +43,6 @@ export interface IDashboardContext {
|
|||||||
) => void;
|
) => void;
|
||||||
variablesToGetUpdated: string[];
|
variablesToGetUpdated: string[];
|
||||||
setVariablesToGetUpdated: React.Dispatch<React.SetStateAction<string[]>>;
|
setVariablesToGetUpdated: React.Dispatch<React.SetStateAction<string[]>>;
|
||||||
|
dashboardQueryRangeCalled: boolean;
|
||||||
|
setDashboardQueryRangeCalled: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user