58 lines
1.9 KiB
TypeScript
Raw Normal View History

import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';
import history from 'lib/history';
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,
}: NavigateToTraceProps): void => {
const urlParams = new URLSearchParams();
urlParams.set(QueryParams.startTime, (minTime / 1000000).toString());
urlParams.set(QueryParams.endTime, (maxTime / 1000000).toString());
history.push(
`${
ROUTES.TRACE
}?${urlParams.toString()}&selected={"serviceName":["${servicename}"],"operation":["${operation}"]}&filterToFetchData=["duration","status","serviceName","operation"]&spanAggregateCurrentPage=1&selectedTags=${selectedTraceTags}&&isFilterExclude={"serviceName":false,"operation":false}&userSelectedFilter={"status":["error","ok"],"serviceName":["${servicename}"],"operation":["${operation}"]}&spanAggregateCurrentPage=1`,
);
};
feat: created a component for apdex (#3283) * feat: created a component for apdex * refactor: added get and set apDexSetting API support * refactor: done with ApDexSetting * feat: done with the traces graph for ApDex * refactor: separated traces using feature flag * refactor: restucture the component level * feat: done with metrics ApDex application * refactor: removed unwanted logs * fix: some css part * refactor: handle error state * refactor: made use of constants and handleGraphClick for apDex * refactor: shifted type to type.ts * chore: css fixes * refactor: handle error and loading state * refactor: one on one mapping * refactor: according to review comments * refactor: removed unwanted color from local theme colors * refactor: one on one mapping for queryKey * refactor: updated css for view traces button issue * chore: commented out the ExcludeStatusCode feature * refactor: updated some css part of ApDexSetting popover * test: added test case for ApDexApplication and ApDexSettings * refactor: test cases * refactor: review comments * refactor: remove the checked for threshold size upto 1 * refactor: changed some text part of ApDex * refactor: only ApDexMetrics inuse * refactor: changes due to merge conflicts * fix: build pipeline * chore: change the type of the threshold * feat: widget header as ReactNode * chore: error for the title is updated * refactor: widget header as Reactnode * refactor: show tooltip when hover over the question icon * refactor: review changes * refactor: convert threadhold to ReactNode * refactor: updated test cases * refactor: move allow threshold a level up * fix: build pipeline * fix: input number issue for value 0 --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com> Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
2023-08-16 12:18:56 +05:30
export const getNearestHighestBucketValue = (
value: number,
buckets: number[],
): string => {
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;
});