Compare commits

...

1 Commits

Author SHA1 Message Date
amlannandy
943a3b2a80 fix: resolve custom time range selection issue in infra monitoring 2025-05-12 17:38:02 +07:00
11 changed files with 199 additions and 151 deletions

View File

@@ -19,6 +19,7 @@ import {
initialQueryState,
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { NANOSECONDS_TO_SECONDS } from 'container/InfraMonitoringK8s/constants';
import {
CustomTimeType,
Time,
@@ -68,12 +69,14 @@ function HostMetricsDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -141,8 +144,8 @@ function HostMetricsDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -161,15 +164,15 @@ function HostMetricsDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -318,8 +321,8 @@ function HostMetricsDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -15,7 +15,10 @@ import {
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { filterDuplicateFilters } from 'container/InfraMonitoringK8s/commonUtils';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import { QUERY_KEYS } from 'container/InfraMonitoringK8s/EntityDetailsUtils/utils';
import {
CustomTimeType,
@@ -64,12 +67,14 @@ function ClusterDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -173,8 +178,8 @@ function ClusterDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -195,15 +200,15 @@ function ClusterDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -403,8 +408,8 @@ function ClusterDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -13,7 +13,10 @@ import {
initialQueryState,
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import {
CustomTimeType,
Time,
@@ -65,12 +68,14 @@ function DaemonSetDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -187,8 +192,8 @@ function DaemonSetDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -209,15 +214,15 @@ function DaemonSetDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -416,8 +421,8 @@ function DaemonSetDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -15,7 +15,10 @@ import {
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { filterDuplicateFilters } from 'container/InfraMonitoringK8s/commonUtils';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import { QUERY_KEYS } from 'container/InfraMonitoringK8s/EntityDetailsUtils/utils';
import {
CustomTimeType,
@@ -67,12 +70,14 @@ function DeploymentDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -189,8 +194,8 @@ function DeploymentDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -211,15 +216,15 @@ function DeploymentDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -424,8 +429,8 @@ function DeploymentDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -13,7 +13,10 @@ import {
initialQueryState,
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import {
CustomTimeType,
Time,
@@ -62,12 +65,14 @@ function JobDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -184,8 +189,8 @@ function JobDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -206,15 +211,15 @@ function JobDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -412,8 +417,8 @@ function JobDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -14,7 +14,10 @@ import {
initialQueryState,
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import { QUERY_KEYS } from 'container/InfraMonitoringK8s/EntityDetailsUtils/utils';
import {
CustomTimeType,
@@ -66,12 +69,14 @@ function NamespaceDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -175,8 +180,8 @@ function NamespaceDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -197,15 +202,15 @@ function NamespaceDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -403,8 +408,8 @@ function NamespaceDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -15,7 +15,10 @@ import {
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { filterDuplicateFilters } from 'container/InfraMonitoringK8s/commonUtils';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import NodeEvents from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityEvents';
import {
CustomTimeType,
@@ -64,12 +67,14 @@ function NodeDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -173,8 +178,8 @@ function NodeDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -195,15 +200,15 @@ function NodeDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -405,8 +410,8 @@ function NodeDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -16,7 +16,10 @@ import {
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { filterDuplicateFilters } from 'container/InfraMonitoringK8s/commonUtils';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import { QUERY_KEYS } from 'container/InfraMonitoringK8s/EntityDetailsUtils/utils';
import {
CustomTimeType,
@@ -55,8 +58,6 @@ import PodTraces from '../../EntityDetailsUtils/EntityTraces';
import { getPodMetricsQueryPayload, podWidgetInfo } from './constants';
import { PodDetailProps } from './PodDetail.interfaces';
const TimeRangeOffset = 1000000000;
// eslint-disable-next-line sonarjs/cognitive-complexity
function PodDetails({
pod,
@@ -68,12 +69,14 @@ function PodDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / TimeRangeOffset), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / TimeRangeOffset), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -190,8 +193,8 @@ function PodDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / TimeRangeOffset),
endTime: Math.floor(maxTime / TimeRangeOffset),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -212,15 +215,15 @@ function PodDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / TimeRangeOffset),
endTime: Math.floor(maxTime / TimeRangeOffset),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -426,8 +429,8 @@ function PodDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / TimeRangeOffset),
endTime: Math.floor(maxTime / TimeRangeOffset),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -13,7 +13,10 @@ import {
initialQueryState,
} from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import EntityEvents from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityEvents';
import EntityLogs from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityLogs';
import EntityMetrics from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityMetrics';
@@ -65,12 +68,14 @@ function StatefulSetDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const urlQuery = useUrlQuery();
@@ -190,8 +195,8 @@ function StatefulSetDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -212,15 +217,15 @@ function StatefulSetDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -419,8 +424,8 @@ function StatefulSetDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
setSelectedView(VIEW_TYPES.METRICS);

View File

@@ -5,7 +5,10 @@ import { Color, Spacing } from '@signozhq/design-tokens';
import { Divider, Drawer, Tooltip, Typography } from 'antd';
import logEvent from 'api/common/logEvent';
import { InfraMonitoringEvents } from 'constants/events';
import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
import {
K8sCategory,
NANOSECONDS_TO_SECONDS,
} from 'container/InfraMonitoringK8s/constants';
import {
CustomTimeType,
Time,
@@ -32,12 +35,14 @@ function VolumeDetails({
GlobalReducer
>((state) => state.globalTime);
const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
minTime,
]);
const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
maxTime,
]);
const startMs = useMemo(
() => Math.floor(Number(minTime) / NANOSECONDS_TO_SECONDS),
[minTime],
);
const endMs = useMemo(
() => Math.floor(Number(maxTime) / NANOSECONDS_TO_SECONDS),
[maxTime],
);
const [modalTimeRange, setModalTimeRange] = useState(() => ({
startTime: startMs,
@@ -68,8 +73,8 @@ function VolumeDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
}, [selectedTime, minTime, maxTime]);
@@ -80,15 +85,15 @@ function VolumeDetails({
if (interval === 'custom' && dateTimeRange) {
setModalTimeRange({
startTime: Math.floor(dateTimeRange[0] / 1000),
endTime: Math.floor(dateTimeRange[1] / 1000),
startTime: Math.floor(dateTimeRange[0] / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(dateTimeRange[1] / NANOSECONDS_TO_SECONDS),
});
} else {
const { maxTime, minTime } = GetMinMax(interval);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
@@ -110,8 +115,8 @@ function VolumeDetails({
const { maxTime, minTime } = GetMinMax(selectedTime);
setModalTimeRange({
startTime: Math.floor(minTime / 1000000000),
endTime: Math.floor(maxTime / 1000000000),
startTime: Math.floor(minTime / NANOSECONDS_TO_SECONDS),
endTime: Math.floor(maxTime / NANOSECONDS_TO_SECONDS),
});
}
onClose();

View File

@@ -8,6 +8,8 @@ import { DataSource } from 'types/common/queryBuilder';
export const DEFAULT_PAGE_SIZE = 10;
export const NANOSECONDS_TO_SECONDS = 1000000000;
export enum K8sCategory {
HOSTS = 'hosts',
PODS = 'pods',