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.

Feat/fill span gaps reset (#3973)

Yunus M58ccbdbec4fe
diff --git a/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphContainer.tsx b/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphContainer.tsx
index 0ac0a74caf..6fcbcaa8c1 100644
--- a/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphContainer.tsx
+++ b/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphContainer.tsx
@@ -13,6 +13,7 @@ function WidgetGraphContainer({
yAxisUnit,
selectedTime,
thresholds,
+ fillSpans = false,
}: WidgetGraphProps): JSX.Element {
const { selectedDashboard } = useDashboard();
@@ -57,6 +58,7 @@ function WidgetGraphContainer({
getWidgetQueryRange={getWidgetQueryRange}
selectedWidget={selectedWidget}
thresholds={thresholds}
+ fillSpans={fillSpans}
/>
);
}
diff --git a/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphs.tsx b/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphs.tsx
index d30cea451d..af5d6722d4 100644
--- a/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphs.tsx
+++ b/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/WidgetGraphs.tsx
@@ -19,6 +19,7 @@ function WidgetGraph({
selectedWidget,
yAxisUnit,
thresholds,
+ fillSpans,
}: WidgetGraphProps): JSX.Element {
const { stagedQuery } = useQueryBuilder();
@@ -26,7 +27,10 @@ function WidgetGraph({
const containerDimensions = useResizeObserver(graphRef);
- const chartData = getUPlotChartData(getWidgetQueryRange?.data?.payload);
+ const chartData = getUPlotChartData(
+ getWidgetQueryRange?.data?.payload,
+ fillSpans,
+ );
const isDarkMode = useIsDarkMode();
@@ -57,6 +61,7 @@ function WidgetGraph({
dimensions: containerDimensions,
isDarkMode,
onDragSelect,
+ fillSpans,
}),
[
widgetId,
@@ -65,6 +70,7 @@ function WidgetGraph({
containerDimensions,
isDarkMode,
onDragSelect,
+ fillSpans,
],
);
@@ -90,6 +96,7 @@ interface WidgetGraphProps {
thresholds: ThresholdProps[];
yAxisUnit: string;
selectedWidget: Widgets;
+ fillSpans: boolean;
getWidgetQueryRange: UseQueryResult<
SuccessResponse<MetricRangePayloadProps, unknown>,
Error
diff --git a/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/index.tsx b/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/index.tsx
index fec25eaa56..e92b17f90a 100644
--- a/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/index.tsx
+++ b/frontend/src/container/NewWidget/LeftContainer/WidgetGraph/index.tsx
@@ -16,6 +16,7 @@ function WidgetGraph({
yAxisUnit,
selectedTime,
thresholds,
+ fillSpans,
}: WidgetGraphProps): JSX.Element {
const { currentQuery } = useQueryBuilder();
const { selectedDashboard } = useDashboard();
@@ -51,6 +52,7 @@ function WidgetGraph({
selectedTime={selectedTime}
selectedGraph={selectedGraph}
yAxisUnit={yAxisUnit}
+ fillSpans={fillSpans}
/>
</Container>
);
diff --git a/frontend/src/container/NewWidget/LeftContainer/index.tsx b/frontend/src/container/NewWidget/LeftContainer/index.tsx
index 64893e8afb..ad48c19a5c 100644
--- a/frontend/src/container/NewWidget/LeftContainer/index.tsx
+++ b/frontend/src/container/NewWidget/LeftContainer/index.tsx
@@ -10,6 +10,7 @@ function LeftContainer({
yAxisUnit,
selectedTime,
thresholds,
+ fillSpans,
}: WidgetGraphProps): JSX.Element {
return (
<>
@@ -18,6 +19,7 @@ function LeftContainer({
selectedTime={selectedTime}
selectedGraph={selectedGraph}
yAxisUnit={yAxisUnit}
+ fillSpans={fillSpans}
/>
<QueryContainer>
<QuerySection selectedTime={selectedTime} selectedGraph={selectedGraph} />
diff --git a/frontend/src/container/NewWidget/RightContainer/index.tsx b/frontend/src/container/NewWidget/RightContainer/index.tsx
index 908c6ef4a3..041b781271 100644
--- a/frontend/src/container/NewWidget/RightContainer/index.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/index.tsx
@@ -1,5 +1,13 @@
import { UploadOutlined } from '@ant-design/icons';
-import { Button, Divider, Input, Select, Space } from 'antd';
+import {
+ Button,
+ Divider,
+ Input,
+ Select,
+ Space,
+ Switch,
+ Typography,
+} from 'antd';
import InputComponent from 'components/Input';
import TimePreference from 'components/TimePreferenceDropDown';
import { QueryParams } from 'constants/query';
@@ -33,6 +41,8 @@ function RightContainer({
thresholds,
setThresholds,
selectedWidget,
+ isFillSpans,
+ setIsFillSpans,
}: RightContainerProps): JSX.Element {
const onChangeHandler = useCallback(
(setFunc: Dispatch<SetStateAction<string>>, value: string) => {
@@ -134,6 +144,15 @@ function RightContainer({
))}
</NullButtonContainer> */}
+ <Space style={{ marginTop: 10 }} direction="vertical">
+ <Typography>Fill span gaps</Typography>
+
+ <Switch
+ checked={isFillSpans}
+ onChange={(checked): void => setIsFillSpans(checked)}
+ />
+ </Space>
+
<Title light="true">Panel Time Preference</Title>
<Space direction="vertical">
@@ -188,6 +207,8 @@ interface RightContainerProps {
thresholds: ThresholdProps[];
setThresholds: Dispatch<SetStateAction<ThresholdProps[]>>;
selectedWidget?: Widgets;
+ isFillSpans: boolean;
+ setIsFillSpans: Dispatch<SetStateAction<boolean>>;
}
RightContainer.defaultProps = {
diff --git a/frontend/src/container/NewWidget/index.tsx b/frontend/src/container/NewWidget/index.tsx
index 1a2e246123..a95c3874e6 100644
--- a/frontend/src/container/NewWidget/index.tsx
+++ b/frontend/src/container/NewWidget/index.tsx
@@ -84,6 +84,9 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
const [selectedNullZeroValue, setSelectedNullZeroValue] = useState<string>(
selectedWidget?.nullZeroValues || 'zero',
);
+ const [isFillSpans, setIsFillSpans] = useState<boolean>(
+ selectedWidget?.fillSpans || false,
+ );
const [saveModal, setSaveModal] = useState(false);
const [graphType, setGraphType] = useState(selectedGraph);
@@ -272,6 +275,7 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
selectedGraph={graphType}
yAxisUnit={yAxisUnit}
thresholds={thresholds}
+ fillSpans={isFillSpans}
/>
</LeftContainerWrapper>
@@ -296,6 +300,8 @@ function NewWidget({ selectedGraph }: NewWidgetProps): JSX.Element {
thresholds={thresholds}
setThresholds={setThresholds}
selectedWidget={selectedWidget}
+ isFillSpans={isFillSpans}
+ setIsFillSpans={setIsFillSpans}
/>
</RightContainerWrapper>
</PanelContainer>
diff --git a/frontend/src/container/NewWidget/types.ts b/frontend/src/container/NewWidget/types.ts
index 77d885077f..83475c0104 100644
--- a/frontend/src/container/NewWidget/types.ts
+++ b/frontend/src/container/NewWidget/types.ts
@@ -7,6 +7,7 @@ import { timePreferance } from './RightContainer/timeItems';
export interface NewWidgetProps {
selectedGraph: PANEL_TYPES;
yAxisUnit: Widgets['yAxisUnit'];
+ fillSpans: Widgets['fillSpans'];
}
export interface WidgetGraphProps extends NewWidgetProps {
diff --git a/frontend/src/lib/uPlotLib/getUplotChartData.ts b/frontend/src/lib/uPlotLib/getUplotChartData.ts
index a3893f7325..f877dffb48 100644
--- a/frontend/src/lib/uPlotLib/getUplotChartData.ts
+++ b/frontend/src/lib/uPlotLib/getUplotChartData.ts
@@ -26,6 +26,7 @@ interface GetUPlotChartOptions {
setGraphsVisibilityStates?: FullViewProps['setGraphsVisibilityStates'];
thresholdValue?: number;
thresholdText?: string;
+ fillSpans?: boolean;
}
export const getUPlotChartOptions = ({
@@ -40,6 +41,7 @@ export const getUPlotChartOptions = ({
setGraphsVisibilityStates,
thresholdValue,
thresholdText,
+ fillSpans,
}: GetUPlotChartOptions): uPlot.Options => ({
id,
width: dimensions.width,
@@ -76,7 +78,7 @@ export const getUPlotChartOptions = ({
},
},
plugins: [
- tooltipPlugin(apiResponse, yAxisUnit),
+ tooltipPlugin(apiResponse, yAxisUnit, fillSpans),
onClickPlugin({
onClick: onClickHandler,
}),
@@ -159,6 +161,7 @@ export const getUPlotChartOptions = ({
apiResponse,
apiResponse?.data.result,
graphsVisibilityStates,
+ fillSpans,
),
axes: getAxes(isDarkMode, yAxisUnit),
});
diff --git a/frontend/src/lib/uPlotLib/plugins/tooltipPlugin.ts b/frontend/src/lib/uPlotLib/plugins/tooltipPlugin.ts
index fabb5ea971..2840b0ffc2 100644
--- a/frontend/src/lib/uPlotLib/plugins/tooltipPlugin.ts
+++ b/frontend/src/lib/uPlotLib/plugins/tooltipPlugin.ts
@@ -15,6 +15,7 @@ const createDivsFromArray = (
idx: number,
yAxisUnit?: string,
series?: uPlot.Options['series'],
+ fillSpans?: boolean,
// eslint-disable-next-line sonarjs/cognitive-complexity
): HTMLElement => {
const container = document.createElement('div');
@@ -32,7 +33,7 @@ const createDivsFromArray = (
div.textContent = formattedDate;
div.classList.add('tooltip-content-header');
- } else if (item.show && data[index][idx]) {
+ } else if (fillSpans ? item.show : item.show && data[index][idx]) {
div.classList.add('tooltip-content');
const color = colors[(index - 1) % colors.length];
@@ -53,9 +54,11 @@ const createDivsFromArray = (
legend || '',
);
- const tooltipValue = getToolTipValue(data[index][idx], yAxisUnit);
+ const value = data[index][idx] || 0;
- text.textContent = `${label} : ${tooltipValue}`;
+ const tooltipValue = getToolTipValue(value, yAxisUnit);
+
+ text.textContent = `${label} : ${tooltipValue || 0}`;
text.style.color = color;
div.appendChild(squareBox);
@@ -72,6 +75,7 @@ const createDivsFromArray = (
const tooltipPlugin = (
apiResponse: MetricRangePayloadProps | undefined,
yAxisUnit?: string,
+ fillSpans?: boolean,
): any => {
let over: HTMLElement;
let bound: HTMLElement;
@@ -132,6 +136,7 @@ const tooltipPlugin = (
idx,
yAxisUnit,
u.series,
+ fillSpans,
);
overlay.appendChild(content);
placement(overlay, anchor, 'right', 'start', { bound });
diff --git a/frontend/src/lib/uPlotLib/utils/getChartData.ts b/frontend/src/lib/uPlotLib/utils/getChartData.ts
index 8850dd315e..b80ccec9dc 100644
--- a/frontend/src/lib/uPlotLib/utils/getChartData.ts
+++ b/frontend/src/lib/uPlotLib/utils/getChartData.ts
@@ -2,6 +2,7 @@ import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
export const getUPlotChartData = (
apiResponse?: MetricRangePayloadProps,
+ fillSpans?: boolean,
): uPlot.AlignedData => {
const seriesList = apiResponse?.data?.result || [];
const uPlotData: uPlot.AlignedData = [];
@@ -14,10 +15,20 @@ export const getUPlotChartData = (
// timestamp
uPlotData.push(new Float64Array(seriesList[0]?.values?.map((v) => v[0])));
+ const numberOfTimestamps = uPlotData[0].length;
+
// for each series, push the values
seriesList.forEach((series) => {
const seriesData = series?.values?.map((v) => parseFloat(v[1])) || [];
+ // fill rest of the value with zero
+ if (seriesData.length < numberOfTimestamps && fillSpans) {
+ const diff = numberOfTimestamps - seriesData.length;
+ for (let i = 0; i < diff; i += 1) {
+ seriesData.push(0);
+ }
+ }
+
uPlotData.push(new Float64Array(seriesData));
});
diff --git a/frontend/src/pages/DashboardWidget/index.tsx b/frontend/src/pages/DashboardWidget/index.tsx
index 9dd439d86c..f26bc6b752 100644
--- a/frontend/src/pages/DashboardWidget/index.tsx
+++ b/frontend/src/pages/DashboardWidget/index.tsx
@@ -57,6 +57,7 @@ function DashboardWidget(): JSX.Element | null {
<NewWidget
yAxisUnit={selectedWidget.yAxisUnit}
selectedGraph={selectedGraph}
+ fillSpans={selectedWidget.fillSpans}
/>
);
}
diff --git a/frontend/src/types/api/dashboard/getAll.ts b/frontend/src/types/api/dashboard/getAll.ts
index c85bbee0bd..2989107013 100644
--- a/frontend/src/types/api/dashboard/getAll.ts
+++ b/frontend/src/types/api/dashboard/getAll.ts
@@ -71,6 +71,7 @@ export interface IBaseWidget {
stepSize?: number;
yAxisUnit?: string;
thresholds?: ThresholdProps[];
+ fillSpans?: boolean;
}
export interface Widgets extends IBaseWidget {
query: Query;