mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-18 07:56:56 +00:00
* feat: custom hook to prevent redundant navigation and handle default params with URL comparison * feat: implement useSafeNavigation to QB, to ensure that the back navigation works properly * fix: handle syncing the relativeTime param with the time picker selected relative time * feat: add support for absolute and relative time sync with time picker component * refactor: integrate safeNavigate in LogsExplorerChart and deprecate the existing back navigation * feat: update pagination query params on pressing next/prev page * fix: fix the issue of NOOP getting converted to Count on coming back from alert creation page * refactor: replace history navigation with safeNavigate in DateTimeSelectionV2 component it also fixes the issue of relativeTime not being added to the url on mounting * feat: integrate useSafeNavigate across service details tabs * fix: fix duplicate redirections by converting the timestamp to milliseconds * fix: replace history navigation with useSafeNavigate in LogsExplorerViews and useUrlQueryData * fix: replace history navigation with useSafeNavigate across dashboard components * fix: use safeNavigate in alert components * fix: fix the issue of back navigation in alert table and sync the pagination with url param * fix: handle back navigation for resource filter and sync the state with url query * fix: fix the issue of double redirection from top operations to traces * fix: replace history.push with safeNavigate in TracesExplorer's updateDashboard * fix: prevent unnecessary query re-runs by checking stagedQuery before redirecting in NewWidget * chore: cleanup * fix: fix the failing tests * fix: fix the documentation redirection failing tests * test: mock useSafeNavigate hook in WidgetGraphComponent test * test: mock useSafeNavigate hook in ExplorerCard test
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import { QueryParams } from 'constants/query';
|
|
import ROUTES from 'constants/routes';
|
|
|
|
import { TopOperationList } from './TopOperationsTable';
|
|
import { NavigateToTraceProps } from './types';
|
|
|
|
export const getErrorRate = (list: TopOperationList): number => {
|
|
if (list.errorCount === 0 && list.numCalls === 0) {
|
|
return 0;
|
|
}
|
|
return (list.errorCount / list.numCalls) * 100;
|
|
};
|
|
|
|
export const navigateToTrace = ({
|
|
servicename,
|
|
operation,
|
|
minTime,
|
|
maxTime,
|
|
selectedTraceTags,
|
|
apmToTraceQuery,
|
|
safeNavigate,
|
|
}: NavigateToTraceProps): void => {
|
|
const urlParams = new URLSearchParams();
|
|
urlParams.set(
|
|
QueryParams.startTime,
|
|
Math.floor(minTime / 1_000_000).toString(),
|
|
);
|
|
urlParams.set(QueryParams.endTime, Math.floor(maxTime / 1_000_000).toString());
|
|
|
|
const JSONCompositeQuery = encodeURIComponent(JSON.stringify(apmToTraceQuery));
|
|
|
|
const newTraceExplorerPath = `${
|
|
ROUTES.TRACES_EXPLORER
|
|
}?${urlParams.toString()}&selected={"serviceName":["${servicename}"],"operation":["${operation}"]}&filterToFetchData=["duration","status","serviceName","operation"]&spanAggregateCurrentPage=1&selectedTags=${selectedTraceTags}&${
|
|
QueryParams.compositeQuery
|
|
}=${JSONCompositeQuery}`;
|
|
|
|
safeNavigate(newTraceExplorerPath);
|
|
};
|
|
|
|
export const getNearestHighestBucketValue = (
|
|
value: number,
|
|
buckets: number[],
|
|
): string => {
|
|
// sort the buckets
|
|
buckets.sort((a, b) => a - b);
|
|
const nearestBucket = buckets.find((bucket) => bucket >= value);
|
|
return nearestBucket?.toString() || '+Inf';
|
|
};
|
|
|
|
export const convertMilSecToNanoSec = (value: number): number =>
|
|
value * 1000000000;
|
|
|
|
export const convertedTracesToDownloadData = (
|
|
originalData: TopOperationList[],
|
|
): Record<string, string>[] =>
|
|
originalData.map((item) => {
|
|
const newObj: Record<string, string> = {
|
|
Name: item.name,
|
|
'P50 (in ms)': (item.p50 / 1000000).toFixed(2),
|
|
'P95 (in ms)': (item.p95 / 1000000).toFixed(2),
|
|
'P99 (in ms)': (item.p99 / 1000000).toFixed(2),
|
|
'Number of calls': item.numCalls.toString(),
|
|
'Error Rate (%)': getErrorRate(item).toFixed(2),
|
|
};
|
|
|
|
return newObj;
|
|
});
|