feat(trace): add trace_id

This commit is contained in:
2026-01-22 16:59:19 +08:00
parent bfb3f93931
commit 7bc7a65a3e
7 changed files with 36 additions and 4 deletions

View File

@@ -85,8 +85,8 @@ impl LogOutput for PostgresOutput {
self.ensure_partition_exists(&record.timestamp).await;
let query = r#"
INSERT INTO app_logs (service_name, log_level, message, module, created_at)
VALUES ($1, $2, $3, $4, $5)
INSERT INTO app_logs (service_name, log_level, message, module, created_at, trace_id)
VALUES ($1, $2, $3, $4, $5, $6)
"#;
// 注意:这里的 write 是在后台任务中执行的,就算慢也不会阻塞主业务
@@ -98,6 +98,7 @@ impl LogOutput for PostgresOutput {
.bind(&record.message)
.bind(&record.module)
.bind(record.timestamp)
.bind(&record.trace_id)
.execute(&self.pool)
.await
{