Skip to content

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

chore: use user (#12891)

Danny Xua98da7336691
diff --git a/backend/api/v1/debug_interceptor.go b/backend/api/v1/debug_interceptor.go
index f988245588..55e173fba1 100644
--- a/backend/api/v1/debug_interceptor.go
+++ b/backend/api/v1/debug_interceptor.go
@@ -18,6 +18,7 @@ import (
"github.com/bytebase/bytebase/backend/metric"
metricplugin "github.com/bytebase/bytebase/backend/plugin/metric"
"github.com/bytebase/bytebase/backend/runner/metricreport"
+ "github.com/bytebase/bytebase/backend/store"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
@@ -83,20 +84,19 @@ func (in *DebugInterceptor) debugInterceptorDo(ctx context.Context, fullMethod s
}
slog.Log(ctx, logLevel, logMsg, "method", fullMethod, log.BBError(err), "latency", fmt.Sprintf("%vms", time.Since(startTime).Milliseconds()))
if st.Code() == codes.Internal && slog.Default().Enabled(ctx, slog.LevelDebug) {
- var role api.Role
- if r, ok := ctx.Value(common.RoleContextKey).(api.Role); ok {
- role = r
- }
-
- in.errorRecordRing.RWMutex.Lock()
- defer in.errorRecordRing.RWMutex.Unlock()
- in.errorRecordRing.Ring.Value = &v1pb.DebugLog{
+ l := &v1pb.DebugLog{
RecordTime: timestamppb.New(time.Now()),
RequestPath: fullMethod,
- Role: string(role),
Error: err.Error(),
StackTrace: string(debug.Stack()),
}
+ user, ok := ctx.Value(common.UserContextKey).(*store.UserMessage)
+ if ok && user != nil {
+ l.User = common.FormatUserEmail(user.Email)
+ }
+ in.errorRecordRing.RWMutex.Lock()
+ defer in.errorRecordRing.RWMutex.Unlock()
+ in.errorRecordRing.Ring.Value = l
in.errorRecordRing.Ring = in.errorRecordRing.Ring.Next()
}
in.metricReporter.Report(ctx, &metricplugin.Metric{
diff --git a/frontend/src/components/DebugLog/DebugLogTable.vue b/frontend/src/components/DebugLog/DebugLogTable.vue
index ae54b23d4d..ec4ce6ed2c 100644
--- a/frontend/src/components/DebugLog/DebugLogTable.vue
+++ b/frontend/src/components/DebugLog/DebugLogTable.vue
@@ -16,10 +16,10 @@
<div>{{ debugLog.requestPath }}</div>
</BBTableCell>
<BBTableCell class="table-cell w-20">
- <span v-if="!debugLog.role" class="italic text-gray-500">{{
+ <span v-if="!debugLog.user" class="italic text-gray-500">{{
$t("debug-log.table.empty")
}}</span>
- <div v-else>{{ debugLog.role }}</div>
+ <div v-else>{{ debugLog.user }}</div>
</BBTableCell>
<BBTableCell class="table-cell pt-3">
<EllipsisText class="max-w-full" :line-clamp="2">{{
@@ -76,7 +76,7 @@ const columnList = computed(() => [
title: t("debug-log.table.request-path"),
},
{
- title: t("debug-log.table.role"),
+ title: t("common.user"),
},
{
title: t("debug-log.table.error"),
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index de9d224216..13c14be1cf 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2895,7 +2895,6 @@
"record-ts": "Time",
"method": "Method",
"request-path": "Request path",
- "role": "Role",
"error": "Error",
"stack-trace": "Stack trace",
"empty": "<Empty>",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 60df7a01f5..5741f40cfd 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2895,7 +2895,6 @@
"record-ts": "Hora",
"method": "Método",
"request-path": "Ruta de solicitud",
- "role": "Rol",
"error": "Error",
"stack-trace": "Rastreo de pila",
"empty": "<Vacío>",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 28dffa3f32..51b395d219 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2895,7 +2895,6 @@
"record-ts": "時間",
"method": "方法",
"request-path": "リクエストパス",
- "role": "役割",
"error": "間違った情報",
"stack-trace": "コールスタック",
"empty": "<なし>",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 67c05a6ec1..f70a7e1394 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2895,7 +2895,6 @@
"record-ts": "时间",
"method": "方法",
"request-path": "请求路径",
- "role": "角色",
"error": "错误消息",
"stack-trace": "调用栈",
"empty": "<无>",
diff --git a/frontend/src/types/proto/v1/actuator_service.ts b/frontend/src/types/proto/v1/actuator_service.ts
index 85798ca475..a12a3a5b4c 100644
--- a/frontend/src/types/proto/v1/actuator_service.ts
+++ b/frontend/src/types/proto/v1/actuator_service.ts
@@ -60,7 +60,7 @@ export interface ListDebugLogResponse {
export interface DebugLog {
recordTime: Date | undefined;
requestPath: string;
- role: string;
+ user: string;
error: string;
stackTrace: string;
}
@@ -482,7 +482,7 @@ export const ListDebugLogResponse = {
};
function createBaseDebugLog(): DebugLog {
- return { recordTime: undefined, requestPath: "", role: "", error: "", stackTrace: "" };
+ return { recordTime: undefined, requestPath: "", user: "", error: "", stackTrace: "" };
}
export const DebugLog = {
@@ -493,8 +493,8 @@ export const DebugLog = {
if (message.requestPath !== "") {
writer.uint32(18).string(message.requestPath);
}
- if (message.role !== "") {
- writer.uint32(26).string(message.role);
+ if (message.user !== "") {
+ writer.uint32(26).string(message.user);
}
if (message.error !== "") {
writer.uint32(34).string(message.error);
@@ -531,7 +531,7 @@ export const DebugLog = {
break;
}
- message.role = reader.string();
+ message.user = reader.string();
continue;
case 4:
if (tag !== 34) {
@@ -560,7 +560,7 @@ export const DebugLog = {
return {
recordTime: isSet(object.recordTime) ? fromJsonTimestamp(object.recordTime) : undefined,
requestPath: isSet(object.requestPath) ? globalThis.String(object.requestPath) : "",
- role: isSet(object.role) ? globalThis.String(object.role) : "",
+ user: isSet(object.user) ? globalThis.String(object.user) : "",
error: isSet(object.error) ? globalThis.String(object.error) : "",
stackTrace: isSet(object.stackTrace) ? globalThis.String(object.stackTrace) : "",
};
@@ -574,8 +574,8 @@ export const DebugLog = {
if (message.requestPath !== "") {
obj.requestPath = message.requestPath;
}
- if (message.role !== "") {
- obj.role = message.role;
+ if (message.user !== "") {
+ obj.user = message.user;
}
if (message.error !== "") {
obj.error = message.error;
@@ -593,7 +593,7 @@ export const DebugLog = {
const message = createBaseDebugLog();
message.recordTime = object.recordTime ?? undefined;
message.requestPath = object.requestPath ?? "";
- message.role = object.role ?? "";
+ message.user = object.user ?? "";
message.error = object.error ?? "";
message.stackTrace = object.stackTrace ?? "";
return message;
diff --git a/frontend/src/views/SettingWorkspaceDebugLog.vue b/frontend/src/views/SettingWorkspaceDebugLog.vue
index c6bde1b65d..32631aec86 100644
--- a/frontend/src/views/SettingWorkspaceDebugLog.vue
+++ b/frontend/src/views/SettingWorkspaceDebugLog.vue
@@ -136,7 +136,7 @@ const logKeyMap = {
recordTime: t("debug-log.table.record-ts"),
method: t("debug-log.table.method"),
requestPath: t("debug-log.table.request-path"),
- role: t("debug-log.table.role"),
+ user: t("common.user"),
error: t("debug-log.table.error"),
stackTrace: t("debug-log.table.stack-trace"),
};
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 90be32cc48..3a76474d13 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -9646,7 +9646,7 @@ components:
format: date-time
requestPath:
type: string
- role:
+ user:
type: string
error:
type: string
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 536dd78622..a2607af302 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -749,7 +749,7 @@ Actuator concept is similar to the Spring Boot Actuator.
| ----- | ---- | ----- | ----------- |
| record_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| request_path | [string](#string) | | |
-| role | [string](#string) | | |
+| user | [string](#string) | | |
| error | [string](#string) | | |
| stack_trace | [string](#string) | | |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 45417f2589..aef3f0c87c 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -3021,7 +3021,7 @@
</tr>
<tr>
- <td>role</td>
+ <td>user</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
diff --git a/proto/generated-go/v1/actuator_service.pb.go b/proto/generated-go/v1/actuator_service.pb.go
index 65c3e6fd2a..65ad00b376 100644
--- a/proto/generated-go/v1/actuator_service.pb.go
+++ b/proto/generated-go/v1/actuator_service.pb.go
@@ -336,7 +336,7 @@ type DebugLog struct {
RecordTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=record_time,json=recordTime,proto3" json:"record_time,omitempty"`
RequestPath string `protobuf:"bytes,2,opt,name=request_path,json=requestPath,proto3" json:"request_path,omitempty"`
- Role string `protobuf:"bytes,3,opt,name=role,proto3" json:"role,omitempty"`
+ User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
StackTrace string `protobuf:"bytes,5,opt,name=stack_trace,json=stackTrace,proto3" json:"stack_trace,omitempty"`
}
@@ -387,9 +387,9 @@ func (x *DebugLog) GetRequestPath() string {
return ""
}
-func (x *DebugLog) GetRole() string {
+func (x *DebugLog) GetUser() string {
if x != nil {
- return x.Role
+ return x.User
}
return ""
}
@@ -708,8 +708,8 @@ var file_v1_actuator_service_proto_rawDesc = []byte{
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x54, 0x69, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f,
0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x71, 0x75,
- 0x65, 0x73, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18,
- 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65,
+ 0x65, 0x73, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18,
+ 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f,
0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x65,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x54, 0x72, 0x61,
diff --git a/proto/v1/actuator_service.proto b/proto/v1/actuator_service.proto
index 65f1b8f9c2..9592dd6ad7 100644
--- a/proto/v1/actuator_service.proto
+++ b/proto/v1/actuator_service.proto
@@ -88,7 +88,7 @@ message DebugLog {
string request_path = 2;
- string role = 3;
+ string user = 3;
string error = 4;