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(ServiceMap): multiple api calls of date picker

Nidhi Tandon245050aac27a
diff --git a/frontend/src/modules/AppWrapper.tsx b/frontend/src/modules/AppWrapper.tsx
index b261ad3e32..17442bd495 100644
--- a/frontend/src/modules/AppWrapper.tsx
+++ b/frontend/src/modules/AppWrapper.tsx
@@ -34,7 +34,13 @@ const App = () => {
<Route path={ROUTES.SIGN_UP} exact component={Signup} />
<Route path={ROUTES.APPLICATION} exact component={ServicesTable} />
<Route path={ROUTES.SERVICE_METRICS} exact component={ServiceMetrics} />
- <Route path={ROUTES.SERVICE_MAP} exact component={ServiceMap} />
+ <Route
+ path={ROUTES.SERVICE_MAP}
+ exact
+ render={(props) => (
+ <ServiceMap {...props} componentPath={ROUTES.SERVICE_MAP} />
+ )}
+ />
<Route path={ROUTES.TRACES} exact component={TraceDetail} />
<Route path={ROUTES.TRACE_GRAPH} exact component={TraceGraph} />
<Route path={ROUTES.SETTINGS} exact component={SettingsPage} />
diff --git a/frontend/src/modules/Servicemap/ServiceMap.tsx b/frontend/src/modules/Servicemap/ServiceMap.tsx
index 048c6980b9..1e0ac23fba 100644
--- a/frontend/src/modules/Servicemap/ServiceMap.tsx
+++ b/frontend/src/modules/Servicemap/ServiceMap.tsx
@@ -1,6 +1,6 @@
-import React, { useEffect, useRef, useState } from "react";
+import React, { useEffect, useRef } from "react";
import { connect } from "react-redux";
-import { RouteComponentProps } from "react-router-dom";
+import { RouteComponentProps, useLocation } from "react-router-dom";
import {
GlobalTime,
serviceMapStore,
@@ -36,6 +36,7 @@ interface ServiceMapProps extends RouteComponentProps<any> {
globalTime: GlobalTime;
getServiceMapItems: Function;
getDetailedServiceMapItems: Function;
+ componentPath: string;
}
interface graphNode {
id: string;
@@ -53,16 +54,19 @@ export interface graphDataType {
const ServiceMap = (props: ServiceMapProps) => {
const fgRef = useRef();
+ const location = useLocation();
const {
getDetailedServiceMapItems,
getServiceMapItems,
globalTime,
serviceMap,
+ componentPath,
} = props;
-
useEffect(() => {
- getServiceMapItems(globalTime);
- getDetailedServiceMapItems(globalTime);
+ if (location.pathname === componentPath) {
+ getServiceMapItems(globalTime);
+ getDetailedServiceMapItems(globalTime);
+ }
}, [globalTime]);
useEffect(() => {