Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: rpc latency (#16752)

Danny Xu00ebb8354596
diff --git a/backend/api/v1/audit_log_service.go b/backend/api/v1/audit_log_service.go
index 4a1e690f0f..8d85432045 100644
--- a/backend/api/v1/audit_log_service.go
+++ b/backend/api/v1/audit_log_service.go
@@ -190,6 +190,7 @@ func convertToAuditLog(ctx context.Context, stores *store.Store, l *store.AuditL
Request: l.Payload.Request,
Response: l.Payload.Response,
Status: l.Payload.Status,
+ Latency: l.Payload.Latency,
ServiceData: l.Payload.ServiceData,
}, nil
}
diff --git a/frontend/src/components/AuditLog/AuditLogDataTable.vue b/frontend/src/components/AuditLog/AuditLogDataTable.vue
index 360afcfbed..69f40ee4a9 100644
--- a/frontend/src/components/AuditLog/AuditLogDataTable.vue
+++ b/frontend/src/components/AuditLog/AuditLogDataTable.vue
@@ -12,6 +12,7 @@
<script lang="tsx" setup>
import { fromBinary } from "@bufbuild/protobuf";
import dayjs from "dayjs";
+import { humanizeDurationV1 } from "@/utils";
import { NDataTable, type DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
@@ -132,8 +133,7 @@ const columnList = computed((): AuditDataTableColumn[] => {
{
key: "status",
resizable: true,
- minWidth: 256,
- width: 256,
+ width: 96,
title: t("audit-log.table.status"),
render: (auditLog) =>
auditLog.status ? (
@@ -142,6 +142,14 @@ const columnList = computed((): AuditDataTableColumn[] => {
"-"
),
},
+ {
+ key: "latency",
+ width: 96,
+ title: t("audit-log.table.latency"),
+ render: (auditLog) => {
+ return <span>{humanizeDurationV1(auditLog.latency)}</span>;
+ },
+ },
{
key: "service-data",
resizable: true,
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 01b028e654..a9e6023db0 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2307,6 +2307,7 @@
"request": "Request",
"response": "Response",
"status": "Status",
+ "latency": "Latency",
"service-data": "Service Data"
},
"advanced-search": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 2702edf56e..aa68234b50 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2307,7 +2307,8 @@
"request": "Pedido",
"response": "Respuesta",
"status": "Estatus",
- "service-data": "Datos del Servicio"
+ "service-data": "Datos del Servicio",
+ "latency": "Estado latente"
},
"advanced-search": {
"scope": {
@@ -2816,4 +2817,4 @@
"last-visit": "Última visita",
"changelog-for-version": "Registro de cambios para {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 63283bd182..c9e5f9b77d 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2307,7 +2307,8 @@
"request": "リクエスト",
"response": "応答",
"status": "ポジション",
- "service-data": "サービスデータ"
+ "service-data": "サービスデータ",
+ "latency": "遅延"
},
"advanced-search": {
"scope": {
@@ -2816,4 +2817,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index b52cb5c435..17b66373c6 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2307,7 +2307,8 @@
"request": "Yêu cầu",
"response": "Phản hồi",
"status": "Trạng thái",
- "service-data": "Dữ liệu dịch vụ"
+ "service-data": "Dữ liệu dịch vụ",
+ "latency": "Độ trễ"
},
"advanced-search": {
"scope": {
@@ -2816,4 +2817,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 9003cc3072..cc2cf2378d 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2307,7 +2307,8 @@
"request": "请求信息",
"response": "响应信息",
"status": "状态",
- "service-data": "服务数据"
+ "service-data": "服务数据",
+ "latency": "延迟"
},
"advanced-search": {
"scope": {
@@ -2816,4 +2817,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index ed0e4c3bf0..41e259da35 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -37,15 +37,51 @@ export function humanizeTs(ts: number): string {
export const humanizeDurationV1 = (
duration: Duration | undefined,
- brief = true
) => {
if (!duration) return "-";
const { seconds, nanos } = duration;
- const total = Number(seconds) + nanos / 1e9;
- if (brief && total <= 1) {
- return "Less than 1s";
+ const totalMs = Number(seconds) * 1000 + nanos / 1e6;
+
+ // For durations less than 1 second, show in milliseconds
+ if (totalMs < 1000) {
+ if (totalMs < 0.01) {
+ return "<0.01ms";
+ }
+ // For sub-10ms, show 2 decimal places for higher precision
+ if (totalMs < 10) {
+ return `${totalMs.toFixed(2)}ms`;
+ }
+ // For 10-100ms, show 1 decimal place
+ if (totalMs < 100) {
+ return `${totalMs.toFixed(1)}ms`;
+ }
+ // For 100ms-1s, show no decimal places
+ return `${totalMs.toFixed(0)}ms`;
+ }
+
+ // For durations between 1-60 seconds, show in seconds with 1 decimal
+ const totalSeconds = totalMs / 1000;
+ if (totalSeconds < 60) {
+ return `${totalSeconds.toFixed(1)}s`;
+ }
+
+ // For durations between 1-60 minutes, show in minutes and seconds
+ const minutes = Math.floor(totalSeconds / 60);
+ if (minutes < 60) {
+ const remainingSeconds = Math.floor(totalSeconds % 60);
+ if (remainingSeconds === 0) {
+ return `${minutes}m`;
+ }
+ return `${minutes}m${remainingSeconds}s`;
+ }
+
+ // For durations over 1 hour, show in hours and minutes
+ const hours = Math.floor(minutes / 60);
+ const remainingMinutes = minutes % 60;
+ if (remainingMinutes === 0) {
+ return `${hours}h`;
}
- return total.toFixed(2) + "s";
+ return `${hours}h${remainingMinutes}m`;
};
export function bytesToString(size: number): string {