mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-26 10:04:26 +08:00
feat: Nan filtering is added (#4000)
* fix: handle nan in uplot * feat: filter for nan is added for metrics * feat: filter for nan is added for metrics --------- Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
This commit is contained in:
parent
c0226ab584
commit
7e87df2d69
@ -28,6 +28,7 @@ function GridCardGraph({
|
|||||||
isQueryEnabled,
|
isQueryEnabled,
|
||||||
threshold,
|
threshold,
|
||||||
variables,
|
variables,
|
||||||
|
filterNaN,
|
||||||
}: GridCardGraphProps): JSX.Element {
|
}: GridCardGraphProps): JSX.Element {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [errorMessage, setErrorMessage] = useState<string>();
|
const [errorMessage, setErrorMessage] = useState<string>();
|
||||||
@ -89,7 +90,11 @@ function GridCardGraph({
|
|||||||
|
|
||||||
const containerDimensions = useResizeObserver(graphRef);
|
const containerDimensions = useResizeObserver(graphRef);
|
||||||
|
|
||||||
const chartData = getUPlotChartData(queryResponse?.data?.payload);
|
const chartData = getUPlotChartData(
|
||||||
|
queryResponse?.data?.payload,
|
||||||
|
undefined,
|
||||||
|
filterNaN,
|
||||||
|
);
|
||||||
|
|
||||||
const isDarkMode = useIsDarkMode();
|
const isDarkMode = useIsDarkMode();
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ export interface GridCardGraphProps {
|
|||||||
headerMenuList?: WidgetGraphComponentProps['headerMenuList'];
|
headerMenuList?: WidgetGraphComponentProps['headerMenuList'];
|
||||||
isQueryEnabled: boolean;
|
isQueryEnabled: boolean;
|
||||||
variables?: Dashboard['data']['variables'];
|
variables?: Dashboard['data']['variables'];
|
||||||
|
filterNaN?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetGraphVisibilityStateOnLegendClickProps {
|
export interface GetGraphVisibilityStateOnLegendClickProps {
|
||||||
|
@ -107,6 +107,7 @@ function DBCall(): JSX.Element {
|
|||||||
<Card data-testid="database_call_rps">
|
<Card data-testid="database_call_rps">
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
<Graph
|
<Graph
|
||||||
|
filterNaN
|
||||||
name="database_call_rps"
|
name="database_call_rps"
|
||||||
widget={databaseCallsRPSWidget}
|
widget={databaseCallsRPSWidget}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
@ -140,6 +141,7 @@ function DBCall(): JSX.Element {
|
|||||||
<Card data-testid="database_call_avg_duration">
|
<Card data-testid="database_call_avg_duration">
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
<Graph
|
<Graph
|
||||||
|
filterNaN
|
||||||
name="database_call_avg_duration"
|
name="database_call_avg_duration"
|
||||||
widget={databaseCallsAverageDurationWidget}
|
widget={databaseCallsAverageDurationWidget}
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
|
@ -148,6 +148,7 @@ function External(): JSX.Element {
|
|||||||
<Card data-testid="external_call_error_percentage">
|
<Card data-testid="external_call_error_percentage">
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
<Graph
|
<Graph
|
||||||
|
filterNaN
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
name="external_call_error_percentage"
|
name="external_call_error_percentage"
|
||||||
widget={externalCallErrorWidget}
|
widget={externalCallErrorWidget}
|
||||||
@ -183,6 +184,7 @@ function External(): JSX.Element {
|
|||||||
<Card data-testid="external_call_duration">
|
<Card data-testid="external_call_duration">
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
<Graph
|
<Graph
|
||||||
|
filterNaN
|
||||||
name="external_call_duration"
|
name="external_call_duration"
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
widget={externalCallDurationWidget}
|
widget={externalCallDurationWidget}
|
||||||
@ -219,6 +221,7 @@ function External(): JSX.Element {
|
|||||||
<Card data-testid="external_call_rps_by_address">
|
<Card data-testid="external_call_rps_by_address">
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
<Graph
|
<Graph
|
||||||
|
filterNaN
|
||||||
name="external_call_rps_by_address"
|
name="external_call_rps_by_address"
|
||||||
widget={externalCallRPSWidget}
|
widget={externalCallRPSWidget}
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
@ -257,6 +260,7 @@ function External(): JSX.Element {
|
|||||||
name="external_call_duration_by_address"
|
name="external_call_duration_by_address"
|
||||||
widget={externalCallDurationAddressWidget}
|
widget={externalCallDurationAddressWidget}
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
|
filterNaN
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(setSelectedTimeStamp)(
|
||||||
xValue,
|
xValue,
|
||||||
|
@ -84,6 +84,7 @@ function ApDexMetrics({
|
|||||||
return (
|
return (
|
||||||
<Graph
|
<Graph
|
||||||
name="apdex"
|
name="apdex"
|
||||||
|
filterNaN
|
||||||
widget={apDexMetricsWidget}
|
widget={apDexMetricsWidget}
|
||||||
onDragSelect={onDragSelect}
|
onDragSelect={onDragSelect}
|
||||||
onClickHandler={handleGraphClick('ApDex')}
|
onClickHandler={handleGraphClick('ApDex')}
|
||||||
|
@ -88,6 +88,7 @@ function ServiceOverview({
|
|||||||
widget={latencyWidget}
|
widget={latencyWidget}
|
||||||
onClickHandler={handleGraphClick('Service')}
|
onClickHandler={handleGraphClick('Service')}
|
||||||
isQueryEnabled={isQueryEnabled}
|
isQueryEnabled={isQueryEnabled}
|
||||||
|
filterNaN
|
||||||
/>
|
/>
|
||||||
</GraphContainer>
|
</GraphContainer>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -27,6 +27,7 @@ function TopLevelOperation({
|
|||||||
) : (
|
) : (
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
<Graph
|
<Graph
|
||||||
|
filterNaN
|
||||||
name={name}
|
name={name}
|
||||||
widget={widget}
|
widget={widget}
|
||||||
onClickHandler={handleGraphClick(opName)}
|
onClickHandler={handleGraphClick(opName)}
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
||||||
|
|
||||||
|
function filterIsNan(
|
||||||
|
value: [number, string],
|
||||||
|
isFilterNaNEnabled?: boolean,
|
||||||
|
): boolean {
|
||||||
|
const val = value[1];
|
||||||
|
return isFilterNaNEnabled ? val !== 'NaN' : true;
|
||||||
|
}
|
||||||
|
|
||||||
export const getUPlotChartData = (
|
export const getUPlotChartData = (
|
||||||
apiResponse?: MetricRangePayloadProps,
|
apiResponse?: MetricRangePayloadProps,
|
||||||
fillSpans?: boolean,
|
fillSpans?: boolean,
|
||||||
|
filterNaN?: boolean,
|
||||||
): uPlot.AlignedData => {
|
): uPlot.AlignedData => {
|
||||||
const seriesList = apiResponse?.data?.result || [];
|
const seriesList = apiResponse?.data?.result || [];
|
||||||
const uPlotData: uPlot.AlignedData = [];
|
const uPlotData: uPlot.AlignedData = [];
|
||||||
@ -19,7 +28,9 @@ export const getUPlotChartData = (
|
|||||||
seriesList[index]?.values?.sort((a, b) => a[0] - b[0]);
|
seriesList[index]?.values?.sort((a, b) => a[0] - b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestampArr = xSeries?.values?.map((v) => v[0]);
|
const timestampArr = xSeries?.values
|
||||||
|
?.filter((response) => filterIsNan(response, filterNaN))
|
||||||
|
.map((v) => v[0]);
|
||||||
|
|
||||||
const uplotDataFormatArr = new Float64Array(timestampArr);
|
const uplotDataFormatArr = new Float64Array(timestampArr);
|
||||||
|
|
||||||
@ -30,7 +41,10 @@ export const getUPlotChartData = (
|
|||||||
|
|
||||||
// for each series, push the values
|
// for each series, push the values
|
||||||
seriesList.forEach((series) => {
|
seriesList.forEach((series) => {
|
||||||
const seriesData = series?.values?.map((v) => parseFloat(v[1])) || [];
|
const seriesData =
|
||||||
|
series?.values
|
||||||
|
?.filter((response) => filterIsNan(response, filterNaN))
|
||||||
|
.map((v) => parseFloat(v[1])) || [];
|
||||||
|
|
||||||
// fill rest of the value with zero
|
// fill rest of the value with zero
|
||||||
if (seriesData.length < numberOfTimestamps && fillSpans) {
|
if (seriesData.length < numberOfTimestamps && fillSpans) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user