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.

fix: table sorting when units are present (#5249)

Vikrant Gupta2a4e97f8da41
diff --git a/frontend/src/container/GridTableComponent/index.tsx b/frontend/src/container/GridTableComponent/index.tsx
index 26bdda1a49..171f09da07 100644
--- a/frontend/src/container/GridTableComponent/index.tsx
+++ b/frontend/src/container/GridTableComponent/index.tsx
@@ -62,10 +62,11 @@ function GridTableComponent({
mutateDataSource = mutateDataSource.map(
(val): RowData => {
- const newValue = val;
+ const newValue = { ...val };
Object.keys(val).forEach((k) => {
if (columnUnits[k]) {
newValue[k] = getYAxisFormattedValue(String(val[k]), columnUnits[k]);
+ newValue[`${k}_without_unit`] = val[k];
}
});
return newValue;
@@ -81,7 +82,6 @@ function GridTableComponent({
applyColumnUnits,
originalDataSource,
]);
-
useEffect(() => {
if (tableProcessedDataRef) {
// eslint-disable-next-line no-param-reassign
diff --git a/frontend/src/lib/query/createTableColumnsFromQuery.ts b/frontend/src/lib/query/createTableColumnsFromQuery.ts
index 28b5b3dc67..c3a5865cd9 100644
--- a/frontend/src/lib/query/createTableColumnsFromQuery.ts
+++ b/frontend/src/lib/query/createTableColumnsFromQuery.ts
@@ -537,8 +537,12 @@ const generateTableColumns = (
width: QUERY_TABLE_CONFIG.width,
render: renderColumnCell && renderColumnCell[item.dataIndex],
sorter: (a: RowData, b: RowData): number => {
- const valueA = Number(a[item.dataIndex]);
- const valueB = Number(b[item.dataIndex]);
+ const valueA = Number(
+ a[`${item.dataIndex}_without_unit`] ?? a[item.dataIndex],
+ );
+ const valueB = Number(
+ b[`${item.dataIndex}_without_unit`] ?? b[item.dataIndex],
+ );
if (!isNaN(valueA) && !isNaN(valueB)) {
return valueA - valueB;